Skip to content

Conversation

@bitfaster
Copy link
Owner

@bitfaster bitfaster commented Dec 19, 2023

During update check if the value is write atomic

  • If it is, just update it in place
  • Else make a new item, update the dictionary (now the item can be read after without tearing), mark the old item as removed and enqueue the new item
    • Queue cannot be updated in place, so we need to pollute with a dupe for this key in this case

The disadvantage of this approach is that for a large number of updates, the effective size of the cache will be reduced. This is not intuitive, and for very heavy update workloads would likely lead to worse write performance than locking on read/lock contention.

@coveralls
Copy link

coveralls commented May 19, 2024

Coverage Status

coverage: 99.141% (+0.01%) from 99.13%
when pulling 9f751d0 on users/alexpeck/tornwrite
into 5483cbf on main.

@bitfaster bitfaster changed the title Mitigate value type torn writes during LRU update Mitigate value type torn writes during LRU update (enqueue) May 20, 2024
@bitfaster
Copy link
Owner Author

Superseded by #593

@bitfaster bitfaster closed this May 26, 2024
@bitfaster bitfaster deleted the users/alexpeck/tornwrite branch May 26, 2024 01:23
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

Successfully merging this pull request may close these issues.

3 participants