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

rework lru's external registered callback invocation to avoid concurr… #80


Copy link

@yigongliu-concur yigongliu-concur commented Dec 5, 2020

  • rework LruCache's invocation of externally registered eviction callback. current code forwards external callback directly into simplelru.LRU, which will invoke the external callback while holding lock at LruCache. this could lead to concurrency issues such as possible deadlock.

  • redo the invocation by passing a internal eviction callback to simplelru.LRU to buffer the evicted keys/vals, and only send them thru external eviction callback after/outside LruCache locks' critical section.

  • running benchmark shows no performance degrade.

Copy link

@jefferai jefferai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@jefferai jefferai merged commit 80c9821 into hashicorp:master Jan 4, 2021
Copy link
Contributor Author

yigongliu-concur commented Jan 5, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

2 participants