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

Null out reference to last stolen fiber #1682

Merged
merged 1 commit into from
Feb 12, 2021
Merged

Null out reference to last stolen fiber #1682

merged 1 commit into from
Feb 12, 2021

Conversation

vasilmkd
Copy link
Member

Not a bug, just a nice, consistent cleanup.

I observed this when stress testing fs2-netty.

When fibers are stolen, the last fiber in the chain of stolen fibers is directly executed. Here, I forgot to null out the reference to this fiber in the local queue which does the stealing. While this exact fiber is executed, a concurrent worker thread might come and steal all other fibers from this same queue. At this point, if there is no more work, all threads will go to sleep but this reference will remain set in the queue.

This is not a bug, safety is still guaranteed because this reference is technically "out" of the circular buffer. It's just that the memory for the already executed fiber will not be reclaimed until new work arrives in the pool, which might take a long time. During this time, that fiber is still strongly referenced in memory and the GC cannot reclaim it.

@djspiewak
Copy link
Member

Awesome catch!

@djspiewak djspiewak merged commit 4b0ad0a into typelevel:series/3.x Feb 12, 2021
@vasilmkd vasilmkd deleted the null-out-ref branch February 12, 2021 23:35
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