Skip to content

Optimize jl_tls_world_age ccall#54537

Merged
topolarity merged 1 commit intomasterfrom
gb/optimize_world_age
Jun 12, 2024
Merged

Optimize jl_tls_world_age ccall#54537
topolarity merged 1 commit intomasterfrom
gb/optimize_world_age

Conversation

@gbaraldi
Copy link
Copy Markdown
Member

This makes it so we avoid a ccall boundary and potentially optimize away repeated world age checks

@gbaraldi gbaraldi requested a review from vtjnash May 21, 2024 17:36
@gbaraldi
Copy link
Copy Markdown
Member Author

With the latest change we avoid any of the wird invariant.load stuff but it still lifts the check to a preheader in a function like

function foo(oc, arr)
       sum = 0.0
           for i in eachindex(arr)
               if (oc.world) == Base.tls_world_age()
                  sum += oc(arr[i])
               else
                   sum += arr[i]
               end
           end
       sum
       end

Copy link
Copy Markdown
Member

@topolarity topolarity left a comment

Choose a reason for hiding this comment

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

Nice! Thanks for iterating on this until all the details were right 👍

@gbaraldi gbaraldi added the merge me PR is reviewed. Merge when all tests are passing label Jun 7, 2024
@topolarity topolarity force-pushed the gb/optimize_world_age branch from 255ef33 to 70e96fe Compare June 12, 2024 02:14
@topolarity topolarity merged commit dfb2fd9 into master Jun 12, 2024
@topolarity topolarity deleted the gb/optimize_world_age branch June 12, 2024 12:36
@oscardssmith oscardssmith added compiler:optimizer Optimization passes (mostly in base/compiler/ssair/) and removed merge me PR is reviewed. Merge when all tests are passing labels Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:optimizer Optimization passes (mostly in base/compiler/ssair/)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants