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 updates the MPSC channel padding after the fix of nim-lang/Nim#13122
There is a tricky compromise for the pledges data structure size:
weave/weave/channels/pledges.nim
Lines 146 to 173 in 71cf681
The
kind
field (1 byte) has to be the first field of PledgePtr, so when theChannelMPSCunbounded[TaskNode]
is made intrusive, the cacheline alignment requirements automatically mades it take over 64 bytes.Also even if the back/count/front are tagged with 64 bytes alignment each (total 192 bytes)
weave/weave/channels/channels_mpsc_unbounded_batch.nim
Lines 50 to 80 in 71cf681
the extra deferredIn, deferredOut, fulfilled fields are not using the extra space after the
front
field:weave/weave/channels/pledges.nim
Lines 160 to 173 in 71cf681
probably because the data structures are distinct.
This makes it impossible to have PledgePtr[] be under 256 bytes. The 3 workarounds are:
Given that before nim-lang/Nim#13122, there was no padding and the MPSC channel could reasonably handle cache line invalidation and that in most MPSC channels implementations there is no padding at all, solution 3 is chosen in this PR