Fit a fiber on a single cache line #2473
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is not production ready. And is also probably not the best combination of fields to achieve 64 bytes of
IOFiber
object footprint.private[this] val
fields which are inside the class body generate abitmap$init
volatile field. I don't exactly know why. However, it can be circumvented (on all Scala versions) by putting the sameprivate[this] val
fields inside the primary constructor for the class. Thus, theseries/3.x
bytecode looks like the following:while, the code in this PR looks like the following:
In other words, much less code in the constructor, and more importantly no writes to a volatile field. This is immediately noticeable in
AsyncBenchmark.start
series/3.x
:This PR
:Here are the comparative benchmarks:
series/3.x
:This PR
:The benchmarks were run using the following snapshot:
I think there is something to this approach and we should pursue it more aggressively. I would really love to see the constructor changes merged. I will split that part out in a separate PR in the next few days.