Skip to content

Remove ThreadLocal from ThreadLocalMap when finishing UndispatchedCor… #3593

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

Merged
merged 3 commits into from
Jan 24, 2023

Conversation

qwwdfsad
Copy link
Member

…outine

  • It addresses the problem with ThreadLocalMap.entries that may outlive the coroutine lifecycle and interfere with CPU consumption of other thread-locals on the same thread
  • No test provided as this is a non-functioanl change. The only reasonable way to check it is to reflectively walk over Thread class which is prohibited by Java since 11+. The only way is to eyeball Thread.currentThread().threadLocals size in debugger in the properly crafted unit test

Fixes #3592

@qwwdfsad
Copy link
Member Author

The next step is not to create thread-local if there doesn't exist the corresponding thread context element

…outine

* It addresses the problem with ThreadLocalMap.entries that may outlive the coroutine lifecycle and interfere with CPU consumption of other thread-locals on the same thread
* No test provided as this is a non-functioanl change. The only reasonable way to check it is to reflectively walk over Thread class which is prohibited by Java since 11+. The only way is to eyeball Thread.currentThread().threadLocals size in debugger in the properly crafted unit test

Fixes #3592
@qwwdfsad qwwdfsad force-pushed the fix-thread-locals-pressure branch from b681d93 to 4d72c30 Compare January 19, 2023 16:57
@qwwdfsad qwwdfsad requested a review from dkhalanskyjb January 19, 2023 17:04
@qwwdfsad qwwdfsad force-pushed the fix-thread-locals-pressure branch from 0f0385a to 9ae227b Compare January 19, 2023 17:26
@qwwdfsad qwwdfsad requested a review from dkhalanskyjb January 23, 2023 18:00
Copy link
Collaborator

@dkhalanskyjb dkhalanskyjb left a comment

Choose a reason for hiding this comment

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

This is a really good explanation! And appropriately scarily long, too, everyone will be sufficiently intimidated by this.

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