Comments (5)
Sure. I'll put together a PR for this and one for #83 when I'm back home. Should work out to fit in tomorrow.
from flurry.
Current best guess for the order of events would be as follows:
- We have a (regular) bin with 1 element, which is the only element in the map (
count == 1
). - That element gets removed by thread 1, which is paused before the call to
add_count
. - An element for the same key is inserted by thread 2, which also is paused before
add_count
(note that all the count updates happen outside of the respective critical sections of the corresponding methods). - Thread 3 now removes this element again, and decrements
count
to0
. - Thread 1 gets to run again and decrements
count
tousize::MAX
. - Thread 2 gets to run and increments
count
to0
.
As of yet unsure as to why this is be a problem for us, but wouldn't be for the Java implementation. There is a validated
boolean in Java's replaceNode
which is omitted in our implementation due to match
/continue
, but I don't see how that would be the culprit.
from flurry.
The Java implementation has all the size information as long
, it's possible that they just
allow this. See also their implementation of size
, which essentially clamps the actual computed value to between 0
and Integer.MAX_INT
. The tree bin test may just be the first to trigger this for us.
It is also possible that the shared counters we don't yet have influence this, there seems to be some kind of contention detection there. There is also this annotation on the counter cells. But I think it is still possible for the computed value to be negative upon call to size
, and that they use long
just so they can perform bounds checks on int
.
from flurry.
That's fascinating... I mean, I suppose we could just move it to an AtomicIsize
instead... I guess they decided it wasn't worth the cost to keep the count accurate at all times. Mind sending a PR?
from flurry.
I can confirm that this was fixed by #88 (perhaps unsurprisingly) after having run it in a loop for a while.
from flurry.
Related Issues (20)
- `#![deny(unsafe_op_in_unsafe_fn)]`
- Fails to build on arm HOT 1
- Memory usage in Flurry Hashmap HOT 16
- Hashmap lacks of get_mut API HOT 1
- Bump ahash dependency version to 0.8.5 HOT 4
- Allow use of pre-hashed keys HOT 1
- Tedious map constructors HOT 2
- Expose non-replacing `insert` HOT 17
- Implement Drain and IntoIterator HOT 2
- Replacing map elements incorrectly decrements the map's element count HOT 2
- Implement `HashSet::replace` HOT 3
- Optimize garbage collection HOT 4
- Run cargo audit in CI? HOT 2
- Racy test failure: treeifying a Moved entry HOT 8
- Racy test failure: segfault in map::tree_bins::concurrent_tree_bin HOT 5
- HashMap enters unreachable code in try_insert HOT 2
- Miri CI invocation needs updating HOT 3
- Use of deprecated `compare_and_swap` and `spin_loop_hint` HOT 1
- Unsoundness in `HashMap::clear` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flurry.