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

More explicit TLS access and GC allocation optimization #17116

Merged
merged 4 commits into from
Jul 3, 2016

Conversation

yuyichao
Copy link
Contributor

@yuyichao yuyichao commented Jun 25, 2016

The main goal of this PR is a small step toward more explicit TLS access in the C code and an experiment of passing TLS pointer around explicitly in the GC. Most of the explicit calls of jl_get_ptls_states() added in this PR (except GC ones and maybe some signal handling ones) do not cross function boundaries.

As for passing the TLS pointer explicitly as function argument, it is faster or the same in most of the case. On Linux, I measured a few percent improvement in GC time (both by running a function with the same allocation pattern or calling GC directly). This improvement might be larger for OSX since, as we recently learned, it doesn't have a static TLS model =(.

However, there is one case where passing the TLS pointer generates slower code (it can increase the pool allocation time by ~15%). My current explanation is that the user (jl_gc_pool_alloc, previously __pool_alloc) only calls this function in a slow branch in the middle of the fast path and keeping an unused value alive increases the register pressure in the fast path.....

This also simplifies and further optimizes GC allocation functions, especially in C. newobj, newstruct, jl_gc_allocobj, jl_gc_alloc_*w, allocb are all merged into jl_gc_alloc and the compile time pool address lookup optimization is generalized to all sizes. This also removes the double initialization of the tag when allocating memory.

This is based on #16893 (which should be ready now) to reduce conflicts. See here for actual diff.

@yuyichao yuyichao added the GC Garbage collector label Jun 25, 2016
@yuyichao yuyichao force-pushed the yyc/threads/chain-ptls branch 4 times, most recently from 50698a0 to 75c3906 Compare July 2, 2016 01:58
Add `typedef jl_ptls_t` to simplify code.
* Pass TLS pointer explicitly to GC allocation functions
* Clean up GC allocation functions to take advantage of compiler constant
  propagation.
* Do not initialize tag twice
* Remove `jl_gc_pool_t::nfree`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GC Garbage collector
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants