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

Optimize account hash CumulativeOffset index from vec to 2-element array #33839

Merged
merged 2 commits into from
Oct 24, 2023

Conversation

HaoranYi
Copy link
Contributor

@HaoranYi HaoranYi commented Oct 24, 2023

Problem

Optimize CumulativeOffset for raw data index during accounts hash calculation.

The raw data is at most 2d. Therefore, instead of using a Vec to store one or two indexes to the data, we can change it to use [usize; 2].

This saves heap allocation and one pointer deref when reading the index.

Summary of Changes

Use [usize; 2] for CumulativeOffset

Fixes #

@HaoranYi HaoranYi changed the title optimize account hash merkle tree index from vec to 2-element array optimize account hash CumulativeOffset index from vec to 2-element array Oct 24, 2023
@HaoranYi HaoranYi changed the title optimize account hash CumulativeOffset index from vec to 2-element array Optimize account hash CumulativeOffset index from vec to 2-element array Oct 24, 2023
@codecov
Copy link

codecov bot commented Oct 24, 2023

Codecov Report

Merging #33839 (73910a7) into master (6470544) will increase coverage by 0.0%.
The diff coverage is 100.0%.

❗ Current head 73910a7 differs from pull request most recent head 911c9d9. Consider uploading reports for the commit 911c9d9 to get more accurate results

@@           Coverage Diff           @@
##           master   #33839   +/-   ##
=======================================
  Coverage    81.8%    81.9%           
=======================================
  Files         809      809           
  Lines      217712   217712           
=======================================
+ Hits       178295   178309   +14     
+ Misses      39417    39403   -14     

Copy link
Contributor

@brooksprumo brooksprumo left a comment

Choose a reason for hiding this comment

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

Nice observation!

accounts-db/src/accounts_hash.rs Outdated Show resolved Hide resolved
@HaoranYi HaoranYi added the automerge Merge this Pull Request automatically once CI passes label Oct 24, 2023
@mergify mergify bot merged commit 9064b8b into solana-labs:master Oct 24, 2023
18 checks passed
@jeffwashington
Copy link
Contributor

looks like a good idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this Pull Request automatically once CI passes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants