Add RwLock and concurrency enabled LinearMemory#136
Conversation
Codecov ReportAttention: Patch coverage is
🚀 New features to boost your workflow:
|
d8c6921 to
23116b1
Compare
|
The code looks good overall, but I would like a soundness check w/r/t to atomic ordering. I'm not super familiar with them, but I know of the importance of getting them right. Perhaps we can make this a topic for tomorrow's meeting Also, for the spinlock, while I have no gripes of setting u32::MAX/2 as a soft-maximum and having u32::MAX as a "writer present flag", it isn't really that rust-y. A rogue |
ad4dc3d to
1e6029f
Compare
|
Mara Bos describes a mechanism to favour writers without having Further information: https://marabos.nl/atomics/building-locks.html#avoiding-writer-starvation |
beae551 to
5126052
Compare
|
@george-cosma @cemonem I tried to apply your feedback, fix the bugs, improve the locking a bit further, now with ordering completely identical to the mara bos book. I also extended the documentation. From my point of view, this PR is good. Please have a look if you find any more gotchas 😄 |
5126052 to
640469b
Compare
In preparation for support of the multiple linear memories proposal, we will need locking. This commit introduces a first version of a naive read-write lock implementation that solely relies on spinning, avoiding any dependence on an operating system. The lock is tailored for the use case in a linear memory which is shared between multiple, concurrently running interpreter instances. Signed-off-by: wucke13 <wucke13+github@gmail.com>
This trait provides methods to convert between values and their canonical representation in little endian byte order. The trait is implemented for all integer types and as well as for `f32` and `f64`. Signed-off-by: wucke13 <wucke13+github@gmail.com>
This implementation of linear memory is capable of being shared between multiple, concurrently running interpreter instances. All access to the actual data goes through raw pointers, derived from `UnsafeCell`s. While this allows race-conditions, it avoids the other kinds of UB that may be caused by code that violates the guarantees attached to shared and mutable references. Signed-off-by: wucke13 <wucke13+github@gmail.com>
This commit integrates the new `LinearMemory` implementation into the interpreter Signed-off-by: wucke13 <wucke13+github@gmail.com>
640469b to
3212000
Compare
Pull Request Overview
Adds:
RwSpinLock, a spinning, writer preferring read-write lock implementationLinearMemory, a linear memory implementation that enable shared concurrent accessTesting Strategy
This pull request was tested by its including tests
TODO or Help
This pull request still needs a keen eye on the use of ordering for the atomic operations in the
RwSpinLockimplementation.Formatting
cargo fmtcargo checkcargo buildcargo docnix fmtGithub Issue
This pull request continues the ideas laid out in #135