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

API: Make maps the right size from the start #5906

Merged
merged 2 commits into from
Jan 17, 2024

Conversation

jannotti
Copy link
Contributor

Should be a tiny gain. It bothered me that we knew the size and didn't use it.

Summary

Test Plan

@jannotti jannotti self-assigned this Jan 17, 2024
Copy link

codecov bot commented Jan 17, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (d383a91) 55.96% compared to head (664aede) 55.97%.

Files Patch % Lines
data/pools/statusCache.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5906      +/-   ##
==========================================
+ Coverage   55.96%   55.97%   +0.01%     
==========================================
  Files         477      477              
  Lines       67463    67463              
==========================================
+ Hits        37754    37764      +10     
+ Misses      27154    27150       -4     
+ Partials     2555     2549       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@algorandskiy algorandskiy left a comment

Choose a reason for hiding this comment

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

so rationale here is the following: since the cache is alive as long as txpool (all along) it is OK to preallocate once because it will grow to this size anyway (in a round under high load or during hundreds of round under low load).
LGTM.

@jannotti jannotti merged commit bb86c36 into algorand:master Jan 17, 2024
18 checks passed
jannotti added a commit to jannotti/go-algorand that referenced this pull request Jan 20, 2024
Don't allocate all the maps ahead of time, when we do allocate them,
allocate them fullsize, and use `struct{}` instead of `bool`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants