fix(memory) BinaryVector fixes for M1 Mac #1429
Merged
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.
Issue
On Mac M1,
incNumBytes
has a quirk. The operation fails with SIGBUS when agetAndAddInt
is invoked on an address offset that is one of the three preceding every multiple of 16. For e.g when addrs is 13, 14, 15, 29, 30, 31, 45, 46, 47 byte offset from the base address, the operationUnsafeUtils.unsafe.getAndAddInt(UnsafeUtils.ZeroPointer, addr, inc)
fails. However, when we do a get and put non atomically, it works. The fix is done to currently unblock developers from using M1 Mac. However, the fix is far from ideal as the data written to the block of memory by FiloDB is application specific and the block of memory is opaque to the operating system, in other words, the OS should not be interpreting this data as long as the application is working on the block it is allocated.IMPORTANT
The PR is built on top of this PR #1428 by @kvpetrov.
Next steps
Once the issue with
UnsafeUtils.unsafe.getAndAddInt(UnsafeUtils.ZeroPointer, addr, inc)
is identified, the changes toBinaryVector.incNumBytes
will be reverted.