-
Notifications
You must be signed in to change notification settings - Fork 601
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
Fix atomic usage on 32-bit systems #260
base: main
Are you sure you want to change the base?
Conversation
The atomic package requires aligned variables (as per the package documentation), but this is not happening for the variables on the stack. Instead change the types for these to 32-bit variables as there should be no need to track 64-bit stats. This fixes various panics from the unaligned memory accesses.
Just coping the linked panic log just to keep it here
|
I'm not sure if going 32 bit is good solution. I understand this may solve the problem but it's limiting the statistics maybe we should consider mutex and locking? We can use channel to and additional gorutine to make this asyc to not slow down Read/Write operations. |
https://golang.org/pkg/sync/atomic/#pkg-note-BUG
I pondered about the reduced tracking, but then questioned whether the code would be reaching 2147483648 hits/misses? |
The atomic package requires aligned variables (as per the package documentation), but this is not happening for the variables on the stack. Instead change the types for these to 32-bit variables as there should be no need to track 64-bit stats.
This fixes various panics from the unaligned memory accesses, such as the one seen at https://ci.debian.net/data/autopkgtest/testing/i386/g/golang-github-allegro-bigcache/9212366/log.gz.