Comments (10)
@lunemec are you using the current master branch that included a race fix? if so, can you create a unit test to replicate that behavior?
from hashmap.
Well, I only noticed when creating kinda huge hashmaps. I tested this with my tests, but it did not trigger. Only when I load real data 70MB in heap, then it triggers this. My current revision is this: b893f49
from hashmap.
I'll try to force the newest commit with the fix - dep automatically takes released version.
from hashmap.
Nope, the current master does not work either. I'll write a test case for this.
from hashmap.
Well, I kinda created this problem:
func TestHashMap_SetWithContainer(t *testing.T) {
type Container struct {
Map HashMap
}
type mapItem struct {
InnerData HashMap
}
var container Container
for i := 0; i < 10; i++ {
var innerMap HashMap
for z := 0; z < 10; z++ {
innerMap.Set(z, struct{}{})
}
container.Map.Set(i, mapItem{InnerData: innerMap})
}
}
from hashmap.
Well at least I can now fix it by simply moving the HashMap outside of the struct, but I have some metadata packed with it, so that would not be ideal.
from hashmap.
@cornelk do you think a fix is possible? Or should I work around this?
from hashmap.
this is the fixed unit test without a race condition:
func TestHashMap_SetWithContainer(t *testing.T) {
type Container struct {
Map *HashMap
}
type mapItem struct {
InnerData *HashMap
}
container := Container{Map: &HashMap{}}
for i := 0; i < 10; i++ {
innerMap := &HashMap{}
for z := 0; z < 10; z++ {
innerMap.Set(z, struct{}{})
}
container.Map.Set(i, mapItem{InnerData: innerMap})
}
}
from hashmap.
Okay, so it was misunderstanding of usage on my part. Could you maybe update readme/doc with a example of this?
from hashmap.
The readme and tests already contain code that shows how to initiate the map: m := &HashMap{}
from hashmap.
Related Issues (20)
- Having break statement while iterating causes goroutine leak HOT 1
- .Get on absent key fatalpanics HOT 1
- the speed for set is really really really low HOT 5
- panic: unsupported key type *foo HOT 3
- Lost writes on table growth HOT 4
- Getting this error when there are many go routines trying to access the value HOT 1
- Question: is possible the values in `left` and `right` are change when inserting a new element? HOT 7
- Panic with Mac M1 and Delve debuger HOT 1
- Thank you HOT 1
- minor version updates break the API HOT 1
- Hang when using GetOrInsert and DEL HOT 3
- Support compound keys
- invalid recursive type atomic.Pointer HOT 3
- 1.19.4 HOT 2
- Unexpected behaviors under large number of data
- [BUG] - Doesn't seem to be thread safe
- i changed some case with grow and the write speed is more quickly than others HOT 1
- Very slow compared to map? HOT 1
- list add method is not correct
- Is it safe to call Del or Set during iterating via Range? 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 hashmap.