Skip to content

Conversation

NHDaly
Copy link
Member

@NHDaly NHDaly commented Apr 26, 2023

This is a follow up to #49508.

The expectation is that this should reduce compilation times (and possibly some dynamic dispatches, but probably not very often), with no penalty for the perf of the produced code, since we're only adding @nospecialize(::Channel) on the functions that don't reference data::Vector{T}.

  • Mark most of the functions on Channels nospecialize when they don't depend on the data type in the Channel, T.
  • Add precompile statement for Base.close(::Channel, ::Exception)

@NHDaly NHDaly force-pushed the nhd-channel-funcs-nospecialize branch 4 times, most recently from 81cbad5 to 9ff5c32 Compare April 26, 2023 05:07
@NHDaly
Copy link
Member Author

NHDaly commented Apr 26, 2023

Are there good threading benchmarks we can run that will exercise Channels sufficiently well to ensure this is perf neutral after compilation and perf-positive if you include compilation?

@NHDaly NHDaly added the multithreading Base.Threads and related functionality label Apr 26, 2023
@jakobnissen
Copy link
Member

jakobnissen commented Apr 26, 2023

I think the @nospecialize f(x) = y syntax doesn't work - or am I wrong?

julia> @nospecialize f(x) = x + 1

julia> f(1)
ERROR: UndefVarError: `f` not defined

If I'm not mistaken, this is why the tests fail. You need to do f(@nospecialize(x::Channel)) = ....

Base automatically changed from nhd-close-channel-excp-nospecialize to master April 26, 2023 14:55
@NHDaly
Copy link
Member Author

NHDaly commented Apr 27, 2023

Oh, thanks. Sad beans! It's interesting because you can of course do

@nospecialize
f(x) = y
@specialize

but i guess the one-function usage isn't supported. Thanks!

- Mark most of the functions on Channels nospecialize when they don't
  depend on the data type in the Channel, `T`.
- Add precompile statement for `Base.close(::Channel, ::Exception)`
@NHDaly NHDaly force-pushed the nhd-channel-funcs-nospecialize branch from 9ff5c32 to 9323ee1 Compare April 27, 2023 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multithreading Base.Threads and related functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants