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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,7 @@ function include_string(mapexpr::Function, mod::Module, code::AbstractString,
@assert Meta.isexpr(ast, :toplevel)
result = nothing
line_and_ex = Expr(:toplevel, loc, nothing)
for ex in ast.args
for ex in (ast::Expr).args
if ex isa LineNumberNode
loc = ex
line_and_ex.args[1] = ex
Expand Down
6 changes: 4 additions & 2 deletions base/logging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Sponsor 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
Sponsor 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
Sponsor 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
Sponsor 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.

logstate = current_logstate()
if std_level >= logstate.min_enabled_level || env_override_minlevel(group, _module)
return logstate.logger
Expand Down Expand Up @@ -516,7 +517,8 @@ end
let _debug_groups_include::Vector{Symbol} = Symbol[],
_debug_groups_exclude::Vector{Symbol} = Symbol[],
_debug_str::String = ""
global function env_override_minlevel(group, _module)
global function env_override_minlevel(group::Union{String,Symbol}, _module::Module)
@nospecialize # block const-prop
debug = get(ENV, "JULIA_DEBUG", "")
if !(debug === _debug_str)
_debug_str = debug
Expand Down