Skip to content

Lookup bindings in the latest world#657

Merged
Keno merged 1 commit intomasterfrom
kf/latestbindingage
Jan 23, 2025
Merged

Lookup bindings in the latest world#657
Keno merged 1 commit intomasterfrom
kf/latestbindingage

Conversation

@Keno
Copy link
Member

@Keno Keno commented Jan 19, 2025

Post-partitioning the executing world age matters for bindings lookup. JuliaInterpreter currently does not model world age correctly. That's a bigger issue. However, for now, just look up bindings in the latest world age, which mostly restores the unpartitioned behavior.

@Keno Keno requested a review from aviatesk January 19, 2025 21:51
Post-partitioning the executing world age matters for bindings lookup.
JuliaInterpreter currently does not model world age correctly.
That's a bigger issue. However, for now, just look up bindings in the
latest world age, which mostly restores the unpartitioned behavior.
Copy link
Member

@aviatesk aviatesk left a comment

Choose a reason for hiding this comment

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

If invokelatest isn’t specified, in which world do these functions perform binding lookups?

Not just in JuliaInterpreter, but for packages using getglobal, I assumed the default lookup world for getglobal would be set to the latest as I believed it would then be non-breaking.

@Keno
Copy link
Member Author

Keno commented Jan 23, 2025

If invokelatest isn’t specified, in which world do these functions perform binding lookups?

The current TLS age of the executing task.

Not just in JuliaInterpreter, but for packages using getglobal, I assumed the default lookup world for getglobal would be set to the latest as I believed it would then be non-breaking.

No, those cannot be the semantics as all global accesses would then have to be inferred to Any in case some other task replaced the binding under your feet after you compiled it.

@Keno Keno merged commit e807fdc into master Jan 23, 2025
5 of 10 checks passed
@aviatesk aviatesk deleted the kf/latestbindingage branch January 24, 2025 05:04
@KristofferC
Copy link
Member

KristofferC commented Jul 23, 2025

This was a quite significant performance hit (the lookup_var change).

Before

julia> function mysum(x)
           s = 0
           for v in x
               s += v
           end
           return s
       end;

# Before
julia> @time @interpret mysum(fill(1, 100000))
  0.566310 seconds (10.40 M allocations: 186.914 MiB, 1.29% gc time)
100000

# After
julia> @time @interpret mysum(fill(1, 100000))
  0.912419 seconds (16.20 M allocations: 280.050 MiB, 0.57% gc time)
100000

anyway to do this in a bit better way?

@Keno
Copy link
Member Author

Keno commented Jul 23, 2025

We can optimize the codegen for this pattern

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