Skip to content

review thread sync and clear references#5506

Merged
kares merged 8 commits intojruby:masterfrom
kares:proper-thread-sync
Dec 15, 2018
Merged

review thread sync and clear references#5506
kares merged 8 commits intojruby:masterfrom
kares:proper-thread-sync

Conversation

@kares
Copy link
Member

@kares kares commented Dec 11, 2018

  • a loop-less runtime.getCurrentContext
  • do not re-create a (context) soft-ref as threads get finalized (unregistered)
  • re-use un-registering logic (clearing refs) with fiber thread disposal
  • thread locals synchronization does not need to lock the RubyThread

the initial motivation was to avoid some soft-references as with tons of fibers they won't get collected until a full gc is run. might still try to look into that direction, these changes should be conservative and maybe help clearing some of those refs (as fibers are done).

also clear out ref when setting null (happens on thread dispose)
this piece gets invoked on RubyThread#dispose (finalize)
thus shall not attempt to adopt thread with getCurrentContext
... at the point this gets invoked refs should be null
@kares kares added this to the JRuby 9.2.6.0 milestone Dec 11, 2018
Copy link
Member

@headius headius left a comment

Choose a reason for hiding this comment

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

Seems generally ok but I had a few questions.

@kares kares force-pushed the proper-thread-sync branch from b1544cf to 47a9e5e Compare December 13, 2018 18:46
@kares kares force-pushed the proper-thread-sync branch from 47a9e5e to 67aab5d Compare December 15, 2018 12:20
unifies the un-registering logic for normal threads vs fibers

also cache volatile data in a local (its assigned on initialize)
@kares kares merged commit 0a804cb into jruby:master Dec 15, 2018
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.

2 participants