Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block const-prop in CoreLogging #39921

Closed
wants to merge 1 commit into from
Closed

Block const-prop in CoreLogging #39921

wants to merge 1 commit into from

Conversation

timholy
Copy link
Member

@timholy timholy commented Mar 5, 2021

It turns out that constant-propagation contributed ~50ms of latency to
Requires.jl. Worse, it does it for each time it's used thanks to
specialization by constant-propagation. This prevents const-specialization
on the Symbol/Module pair in env_override_minlevel.

It turns out that constant-propagation contributed ~50ms of latency to
Requires.jl. Worse, it does it for each time it's used thanks to
specialization by constant-propagation. This prevents specialization
on the Symbol/Module pair in `env_override_minlevel`.
@@ -474,7 +474,8 @@ function current_logstate()
end

# helper function to get the current logger, if enabled for the specified message type
@noinline function current_logger_for_env(std_level::LogLevel, group, _module)
@noinline function current_logger_for_env(std_level::LogLevel, group::Union{String,Symbol}, _module::Module)
@nospecialize # block const-prop
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this actually blocks constant prop in inference (does it?) --- but it probably should!

Copy link
Member Author

@timholy timholy Mar 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe not reliably. But it it seems to help in some cases. E.g., I've used it several times on keyword arguments to prevent #38983 (comment).

There was definitely a big difference in inference timing here and the const-prop didn't show up any more in @snoopi_deep recordings, but you're right that it doesn't always seem to prevent const-prop.

EDIT: now I'm not so sure it helps in this specific case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these types are correct either. I'm pretty sure ::Any was right

Copy link
Member Author

@timholy timholy Mar 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test failures definitely say we need at least Nothing.

@timholy
Copy link
Member Author

timholy commented Mar 5, 2021

Hmm, I must have conflated this with other changes I was making in JuliaPackaging/Requires.jl#101. Now I really don't see any difference in inference. Unless it's LLVM time?

@timholy
Copy link
Member Author

timholy commented Mar 5, 2021

Happy to close if this is useless.

@timholy timholy closed this Mar 5, 2021
@timholy timholy deleted the teh/requires_latency branch March 5, 2021 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants