Comments (6)
@alphadose https://secondboyet.com/Articles/LockFreeLinkedList3.html is a better explanation. https://github.com/G-M-twostay/Go-Utils/blob/master/Maps/ChainMap/Node.go.
Harris's linked list originally used pointer tagging in C++, but unfortunately that's impossible in Go in my knowledge due to garbage collection.
from haxmap.
@G-M-twostay understood, I will take a look at this. Might be related to #23
from haxmap.
If I were correct about the race condition, then to solve it, simply enforce consistency between node.next and node.delete. One such way is to make use an additional struct to combine these 2 fields and directly operate on the immutable struct.
from haxmap.
@G-M-twostay I couldn't understand your solution completely. Can you give me an example code snippet ?
from haxmap.
I am looking at haxmap but am a bit concerned by this issue. After playing with it a bit, it appears it may be related to a race condition while resizing.
I can repro the error easily with @G-M-twostay's code, even as a Test and not a Benchmark. But, if I allocate the haxmap with a larger initial capacity, the error does not appear.
// Old
M := haxmap.New[int, int]()
// New
M := haxmap.New[int, int](iter0 * elementNum0)
-- EDIT
It looks like this is a known "issue". I just saw this in the docs:
If a resizing operation is happening concurrently while calling Set() then the item might show up in the map only after the resize operation is finished
from haxmap.
I am looking at haxmap but am a bit concerned by this issue. After playing with it a bit, it appears it may be related to a race condition while resizing.
I can repro the error easily with @G-M-twostay's code, even as a Test and not a Benchmark. But, if I allocate the haxmap with a larger initial capacity, the error does not appear.
// Old M := haxmap.New[int, int]() // New M := haxmap.New[int, int](iter0 * elementNum0)-- EDIT
It looks like this is a known "issue". I just saw this in the docs:
If a resizing operation is happening concurrently while calling Set() then the item might show up in the map only after the resize operation is finished
I believe it's related to deletion.
from haxmap.
Related Issues (20)
- CompareAndStore would be nice HOT 6
- Seems not thread safe HOT 3
- Can't get data after multiple sets HOT 6
- If there were any considering support LRU? HOT 1
- Finding this project... HOT 1
- GetOrSet race? HOT 6
- UUID for Key? HOT 1
- Json encoding support
- Missed func LoadAndDelete
- Set after Delete seems to delete key HOT 1
- Unnecessary resizing
- Incorrect fillrate value
- Slow compared to map?
- Plan for new release HOT 1
- now we can use xxh3 to speed up HOT 9
- New() initializer panics if the given size is uintptr(0) HOT 2
- Add clear all method HOT 2
- Save to file, load from file HOT 5
- [Question]: why are there empty structs in atomic? 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 haxmap.