Comments (4)
Your hot fix looks good to me, but I don’t understand the two points you made above. The issue is just that there are two concurrent goroutines loading the same cache value at the same time and they both end up modifying the visited field because they’re not holding an exclusive lock.
another alternative would be to add a sub-lock inside the entry struct and acquire that before marking visited as true. For now though I’d probably merge your existing hot fix since the more complex solutions probably require detailed concurrent benchmarking.
from golang-fifo.
I could see this being an intentional performance thing if setting a boolean field compiles down to a single instruction 🤔 but it makes using this library in any codebase that runs tests with the race detector enabled impossible
from golang-fifo.
@richardartoul Thank you for reporting.
I've researched one thing that can cause this.
- Go map is not addressable which means the pointed value may change during performing operations
- Changes in pointed value can occur when go map rebalances itself to ensure O(1) access.
I think that there are two possible solutions here
- Simply change
RLock
toLock
to make all operations work sequentially - Adopt a concurrent-map implementation like this or
sync.Map
Hot Fixes
This is a critical bug, I'll handle it with a hotfix and conduct further researchs for this.
from golang-fifo.
I also want to hear @richardartoul opinions about this.
from golang-fifo.
Related Issues (18)
- Feedback on a statement HOT 6
- Add a test code for SIEVE. HOT 1
- [FEATURE] Implement expirable SIEVE & S3-FIFO. HOT 1
- [FEATURE] Non-generic optimized cache algorithm HOT 3
- [FEATURE] Lock-free implementation HOT 1
- [ENHANCEMENT] Enhance performance HOT 4
- Add CI pipeline
- not an issue, just a thanks HOT 1
- Proper implementation of bucket table.
- Improve worst-case time complexity. HOT 1
- Add concurrent test & make coverage to be greater than 90 percent
- Implementation of the `ShardedCache` HOT 2
- Bump up Go version to `1.22`
- Replace built-in hash map to `Swiss Table` HOT 2
- Update the benchmark result.
- I read the paper and saw only 21 lines modification to golang code is needed to convert to be sieve?
- OnEvictCallback called for non-evictions HOT 1
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 golang-fifo.