I have a strange problem testing OTP 25 RC1 on OSX (with JIT enabled).
I tried to test the leveled database (GitHub - martinsumner/leveled: A pure Erlang Key/Value store - based on a LSM-tree, optimised for HEAD requests) today on OTP 25 RC1. Compiles OK, dialyzer is OK, but the eunit tests fail.
The interesting failure is in the leveled_ebloom module. This purpose of the module is to create a bloom filter like structure for checking existence of keys. The way it works is to take a hash of the key and split it into a slot and two hashes, the bloom is split into slots, and the two hashes are then added to the slot using bor
. The number of slots varies depending on the number of hashes the bloom has to hold.
The failing test creates lots of random keys (hence hashes), and then builds a bloom, then checks all the keys/hashes are confirmed as in the bloom.
It seems odd that such a simple thing would be broken by an OTP change, but it is (on my machine).
If we run the test on OTP 25 it consistently fails (and it consistently passes on all other OTP versions). The bloom is created, but some of the hashes added to the bloom are not found. Mysteriously, it only fails on hashes were the Slot is 2 mod 16. All other keys (that fall into a Slot which is not 2 mod 16) are found OK.
Putting some print statements in as the hash is built, I have discovered that the calculation S2 bor Mask
such as found here or here or [here(leveled/leveled_ebloom.erl at develop-3.1 · martinsumner/leveled · GitHub) is being truncated to just a 32 bit output. But only for these Slots, and not for the other lines above and below associated with Slots which are not 2 mod 16.
I’ve tested this on an Ubuntu machine with OTP 25 but without JIT, and the test passes fine. So this is either OSX or JIT specific. I’m going to setup an Ubuntu machine with JIT now to see if it is JIT or OS specific.
Once I have done that I will update, and then try and simplify the test case. However, I thought I would share now, as this is driving me a bit crazy.