Skip to content

Transfer tick state when replacing a blocked thread#4264

Merged
djspiewak merged 2 commits into
typelevel:series/3.6.xfrom
armanbilge:bug/blocking-starvation
Feb 5, 2025
Merged

Transfer tick state when replacing a blocked thread#4264
djspiewak merged 2 commits into
typelevel:series/3.6.xfrom
armanbilge:bug/blocking-starvation

Conversation

@armanbilge

Copy link
Copy Markdown
Member

No description provided.

@armanbilge armanbilge added this to the v3.6.0 milestone Feb 2, 2025

private[effect] object WorkerThread {

private[unsafe] final class TransferState {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is TransferState mutable just to avoid always allocating a new instance? Or am I missing something?

(Also, a possibly stupid idea: we could pack the 2 Ints into one Long... I think that way the transferState field could be avoided. But also, that would cause java.lang.Long object allocations when transferring...)

@armanbilge armanbilge Feb 3, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is TransferState mutable just to avoid always allocating a new instance?

Yes, that's right.

But also, that would cause java.lang.Long object allocations when transferring...

Yes, and they would be unlikely to be cached. The old implementation transferring java.lang.Integers were likely to be cached due to their relatively small values (likely < 64, except on some very large machines).

I think if we want to do better here, we'd need to implement a custom concurrent data structure for transfers.

@djspiewak
djspiewak merged commit 65c5ba8 into typelevel:series/3.6.x Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants