Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kyri-petrou
Copy link
Contributor

With this PR we store references to mutable objects in vals within the ZWorker#run method. This way we avoid reading them from the heap, reducing the potential of their value being invalidated in case they fall in a cache line that contains a variable that is regularly updated

if (currentBlocking) {
val runnables = localQueue.pollUpTo(256)
if (runnables.nonEmpty) {
if (!runnables.isEmpty) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this because of the interface dispatch? I think we could override it even though it's marked deprecatedOverriding

Copy link
Contributor Author

@kyri-petrou kyri-petrou May 20, 2025

Choose a reason for hiding this comment

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

Is this because of the interface dispatch

Yeap

I think we could override it

I'm a bit worried that it'll make things a bit worse for the rest of the std library collections. My knowledge on the matter is not the best but I think that the more overrides a method has, it makes interface dispatches for that method slower. I could be wrong on that though, I vaguely remember reading that somewhere.

@kyri-petrou kyri-petrou merged commit 91f98c7 into zio:series/2.x May 20, 2025
18 checks passed
@kyri-petrou kyri-petrou deleted the improve-zscheduler-mutable-references branch May 20, 2025 15:22
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