tisonkun commented on PR #330:
URL:
https://github.com/apache/datasketches-rust/pull/330#issuecomment-6763224524
@Waterpine I reproduced the 32-bit compatibility issue described in the PR
using actual `wasm32-unknown-unknown` builds of the base (`4ba130e`) and PR
head (`7615853`), executed in Node.
Please preserve the existing bit mapping in this performance PR, including
the truncation before the right shift on 32-bit targets, and handle the
cross-platform compatibility correction separately with an explicit migration
strategy.
The change makes an existing filter silently return false negatives after a
32-bit application upgrades. Deserialization succeeds, and the serialized
format does not distinguish the two mappings. With 192 bits, three hashes, seed
9001, and just `0u64` inserted, the old wasm32 build sets bits `11, 19, 26`;
the new build sets `75, 83, 154`.
### Minimal reproduction
Generate the filter on the base revision targeting wasm32:
```rust
use datasketches::bloom::BloomFilterBuilder;
let mut filter = BloomFilterBuilder::with_size(192, 3)
.seed(9001)
.build()
.unwrap();
filter.insert(0u64);
assert!(filter.contains(&0u64));
let bytes = filter.serialize();
```
The following embeds those exact serialized bytes and fails on the PR head
with the `bloom` feature enabled:
```rust
use datasketches::bloom::BloomFilter;
fn main() {
let hex =
"0401150003000000292300000000000003000000000000000300000000000000000808040000000000000000000000000000000000000000";
let bytes: Vec<u8> = (0..hex.len())
.step_by(2)
.map(|i| u8::from_str_radix(&hex[i..i + 2], 16).unwrap())
.collect();
let filter = BloomFilter::deserialize(&bytes).unwrap();
assert!(filter.contains(&0u64)); // Fails: an inserted item is missing.
}
```
The wasm32 producer/consumer results are:
| Producer | Consumer | `contains(&0u64)` |
| -------- | -------- | ----------------- |
| Base | Base | `true` |
| Base | PR head | `false` |
| PR head | Base | `false` |
| PR head | PR head | `true` |
This also breaks rollback. The fixture fails on 64-bit builds too, but old
32-bit/64-bit interoperability was already broken before this PR; the new
regression is the same-platform 32-bit upgrade path.
The effects extend beyond `contains`: `contains_and_insert` reports an
existing item as absent. Mixing an old filter with a freshly built filter
passes `is_compatible`, yet union into an empty filter misses the old item,
intersection can lose a shared item, and difference can retain an item present
in the right-hand filter. These operations return success. Deserializing and
serializing again does not repair the mapping.
### About splitting the hashing change
The `XxHash64::write_u64` change affects Bloom and XOR. Count-Min uses
`MurmurHash3X64128`, so it is not affected by this change; please correct that
scope in the PR description.
Splitting the hashing optimization into a separate PR is fine and would make
its validation easier to review, but I do not require a split. Keeping it here
is also fine, with coverage for both Bloom and XOR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]