-
Notifications
You must be signed in to change notification settings - Fork 159
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
Implement chain index #855
Conversation
loop { | ||
let pts = self.load_tipset(ts.parents()).await?; | ||
|
||
if to > pts.epoch() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing this to detect for empty epochs? Had to stare at that for a hot sec to see why this would ever happen lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah exactly haha
where | ||
BS: BlockStore + Send + Sync + 'static, | ||
{ | ||
if let Some(ts) = cache.write().await.get(tsk) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use cache.read()
here instead of getting a write lock?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's a least recently used (LRU) cache, and it needs to update the position of the entry on read to function correctly, which requires mutable access. There is a method called peek
on this cache, which only requires immutable access, but that defeats the purpose of this cache.
Yes this limits the concurrent reads, but the lock is kept for a very short amount of time and this means that frequently accessed keys don't get evicted from the cache early
Summary of changes
Changes introduced in this pull request:
Reference issue to close (if applicable)
Closes #814
Other information and links