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

feat(indexer): Improve cache memory efficiency #260

Merged
merged 1 commit into from
Apr 13, 2022
Merged

Conversation

Yawning
Copy link
Contributor

@Yawning Yawning commented Apr 10, 2022

Instead of using a complicated cache implementation, just use a handful
of sync.Maps along with a "remove eldest" replacement policy. Since our
critical-path access patterns are overwhelmingly for temporally recent data
the new policy also makes it impossible for the hot dataset to be evicted.

Implements #252

@codecov
Copy link

codecov bot commented Apr 10, 2022

Codecov Report

Merging #260 (dfccdc6) into main (e1ee3c9) will decrease coverage by 0.85%.
The diff coverage is 87.58%.

❗ Current head dfccdc6 differs from pull request most recent head 342ea05. Consider uploading reports for the commit 342ea05 to get more accurate results

@@            Coverage Diff             @@
##             main     #260      +/-   ##
==========================================
- Coverage   63.04%   62.18%   -0.86%     
==========================================
  Files          34       34              
  Lines        3810     3819       +9     
==========================================
- Hits         2402     2375      -27     
- Misses       1207     1246      +39     
+ Partials      201      198       -3     
Impacted Files Coverage Δ
conf/config.go 43.47% <ø> (ø)
indexer/backend.go 47.76% <ø> (-0.75%) ⬇️
indexer/backend_cache.go 72.78% <86.98%> (+5.40%) ⬆️
indexer/indexer.go 47.64% <100.00%> (+1.12%) ⬆️
indexer/utils.go 75.61% <100.00%> (+0.30%) ⬆️
db/model/model.go 0.00% <0.00%> (-85.94%) ⬇️
storage/psql/psql.go 61.47% <0.00%> (-0.44%) ⬇️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1ee3c9...342ea05. Read the comment docs.

@Yawning Yawning force-pushed the yawning/feature/252 branch 5 times, most recently from 431fd93 to d59f37c Compare April 11, 2022 03:36
@Yawning Yawning marked this pull request as ready for review April 11, 2022 03:41
@Yawning
Copy link
Contributor Author

Yawning commented Apr 11, 2022

While I am marking this ready for review, I'm not sure how much of a performance difference this will make.

Instead of using a complicated cache implementation, just use a handful
of sync.Maps along with a "remove eldest" replacement policy.
Receipts []*model.Receipt
Block *model.Block
Receipts []*model.Receipt
UniqueTxes []*model.Transaction
Copy link
Member

Choose a reason for hiding this comment

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

Oh, yeah this is correct, I shouldn't have changed this

@Yawning Yawning merged commit 7468b46 into main Apr 13, 2022
@Yawning Yawning deleted the yawning/feature/252 branch April 13, 2022 11:53
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.

None yet

2 participants