Skip to content
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

The function 'slice.IndexOf' is not thread-safe #262

Closed
SinuxLee opened this issue Oct 31, 2024 · 6 comments
Closed

The function 'slice.IndexOf' is not thread-safe #262

SinuxLee opened this issue Oct 31, 2024 · 6 comments

Comments

@SinuxLee
Copy link

I get this information when I execute this function on different coroutines.

fatal error: concurrent map writes

goroutine 1483221 [running]:
github.com/duke-git/lancet/v2/slice.IndexOf[...]({0xc0026e2ea0, 0x6, 0x6}, {0x0, 0x0})
        .../go/pkg/mod/github.com/duke-git/lancet/v2@v2.3.3/slice/slice.go:1196 +0x54f

@duke-git
Copy link
Owner

I get this information when I execute this function on different coroutines.

fatal error: concurrent map writes

goroutine 1483221 [running]:
github.com/duke-git/lancet/v2/slice.IndexOf[...]({0xc0026e2ea0, 0x6, 0x6}, {0x0, 0x0})
        .../go/pkg/mod/github.com/duke-git/lancet/v2@v2.3.3/slice/slice.go:1196 +0x54f

The methods of slice package are not goroutines safe and requires a lock to ensure goroutines safety.

@SinuxLee
Copy link
Author

I get this information when I execute this function on different coroutines.

fatal error: concurrent map writes

goroutine 1483221 [running]:
github.com/duke-git/lancet/v2/slice.IndexOf[...]({0xc0026e2ea0, 0x6, 0x6}, {0x0, 0x0})
        .../go/pkg/mod/github.com/duke-git/lancet/v2@v2.3.3/slice/slice.go:1196 +0x54f

The methods of slice package are not goroutines safe and requires a lock to ensure goroutines safety.

Can we change memoryHashMap and memoryHashCounter to sync.map to support concurrency ? Looking forward to your reply.

@duke-git
Copy link
Owner

I get this information when I execute this function on different coroutines.

fatal error: concurrent map writes

goroutine 1483221 [running]:
github.com/duke-git/lancet/v2/slice.IndexOf[...]({0xc0026e2ea0, 0x6, 0x6}, {0x0, 0x0})
        .../go/pkg/mod/github.com/duke-git/lancet/v2@v2.3.3/slice/slice.go:1196 +0x54f

The methods of slice package are not goroutines safe and requires a lock to ensure goroutines safety.

Can we change memoryHashMap and memoryHashCounter to sync.map to support concurrency ? Looking forward to your reply.

Okay, you can submit a PR to change it.

@cannian1
Copy link
Collaborator

I get this information when I execute this function on different coroutines.

fatal error: concurrent map writes

goroutine 1483221 [running]:
github.com/duke-git/lancet/v2/slice.IndexOf[...]({0xc0026e2ea0, 0x6, 0x6}, {0x0, 0x0})
        .../go/pkg/mod/github.com/duke-git/lancet/v2@v2.3.3/slice/slice.go:1196 +0x54f

The methods of slice package are not goroutines safe and requires a lock to ensure goroutines safety.

Can we change memoryHashMap and memoryHashCounter to sync.map to support concurrency ? Looking forward to your reply.

Okay, you can submit a PR to change it.

I think we should evaluate the performance overhead of sync.Map and map + RWLock in here.

@duke-git
Copy link
Owner

duke-git commented Nov 1, 2024

@cannian1 make sense, we should evaluate the performance here.

@duke-git
Copy link
Owner

duke-git commented Dec 4, 2024

fixed in v2.3.4

@duke-git duke-git closed this as completed Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants