-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot set maps above a certain size #2
Comments
Hi @nightwolfz , can you try it with an initial size such as Also you are allocating the hashmap in each round of the for loop, can you move it outside the loop or is that intentional ? |
@alphadose That's just an example to illustrate the issue. You can simplify it to func TestMakeHaxmap(t *testing.T) {
m := haxmap.New[int, string]()
for i := 0; i < 65000; i++ {
m.Set(i, fmt.Sprintf("a%d", i))
}
t.Logf("size: %d", m.Size())
} At test.cpu=1, this hangs indefinitely at around 5500 If I add If this is by design, it might be worth mentioning in the README. |
@nightwolfz yes rapid map growth via One of haxmap's future goals is a better growth policy which wont choke and hence there is lots more room for improvement
Yes, I will mention it Also the current workaround for this behaviour would be initializing the map with a good size which will cause lesser grow operations and wont choke |
A few ideas for https://github.com/alphadose/haxmap/blob/main/map.go#L140
if resizeNeeded(uintptr(len(data.index)), count) {
runtime.Gosched()
if m.resizing.CompareAndSwap(notResizing, resizingInProgress) {
go m.grow(0, true)
}
}
if resizeNeeded(uintptr(len(data.index)), count) && m.resizing.CompareAndSwap(notResizing, resizingInProgress) {
m.growSync(0, true)
}
|
Yes, this sounds plausible, if possible can you checkout a branch with these changes ? It would be much easier for both of us to test that way. I like the 2nd option:- letting everything happen in sync |
@nightwolfz I have updated the main branch with this d071dd5 With this commit growth happens synchronously and the benchmarks and tests are passing as well can you run your tests once again and tell me the results ? |
Much better now. |
go 1.19
Randomly hangs forever...
The text was updated successfully, but these errors were encountered: