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

tune ancient append vec size to 128M #34067

Merged
merged 4 commits into from
Dec 11, 2023
Merged

Conversation

HaoranYi
Copy link
Contributor

@HaoranYi HaoranYi commented Nov 14, 2023

Problem

There is a trade-off for selecting the ancient append vec size. Too small size will result in
too many ancient append vec memory mapped files. Too big size will make it difficult to clean and shrink.
Here, we choose 128M bytes for the ancient append vec size.

Summary of Changes

set ancient append vec size to 128M

Fixes #

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.

My two cents 😸

Comment on lines 924 to 929
const PAGE_SIZE: u64 = 4 * 1024;

// There is a trade-off for selecting the ancient append vec size. Too small size will result in
// too many ancient append vec memory mapped files. Too big size will make it difficult to clean and shrink.
// Hence, we choose approximately 130MB (i.e. 134,217,728 bytes) for the ancient append vec size.
const RESULT: u64 = PAGE_SIZE * 32768;
Copy link
Contributor

@brooksprumo brooksprumo Nov 14, 2023

Choose a reason for hiding this comment

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

One reason for choosing 128 MiB is that it's a power of two and then we can steal bits off the top of offsets into these files. I think it could be useful to include that in the "why" comments. (We can say 128 MiB too, instead of approximately 130 MB.)

Other options for specifying the size are:

  • 128 * 1024 * 1024 (makes it obvious the size is 128 MiB)
  • 1 << 27 (makes it obvious we have 5 bits to spare on a u32)

For the asserts, we could also add why it's necessary that ancient append vecs are smaller than non-ancient. (Just as a comment, not within the assert!(). Same for why we want a multiple of 4 KiB.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds reasonable to me. @jeffwashington wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with however you want to specify the size.
I'd like to see the assert remain so we connect these two 'constants'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure. updated.

Copy link

codecov bot commented Nov 15, 2023

Codecov Report

Merging #34067 (eb5dfc8) into master (71dcf77) will decrease coverage by 0.1%.
Report is 30 commits behind head on master.
The diff coverage is 100.0%.

Additional details and impacted files
@@            Coverage Diff            @@
##           master   #34067     +/-   ##
=========================================
- Coverage    81.9%    81.9%   -0.1%     
=========================================
  Files         811      811             
  Lines      219628   219627      -1     
=========================================
- Hits       179974   179941     -33     
- Misses      39654    39686     +32     

@HaoranYi HaoranYi changed the title tune ancient append vec size to 130M tune ancient append vec size to 128M Nov 15, 2023
brooksprumo
brooksprumo previously approved these changes Nov 16, 2023
// too many ancient append vec memory mapped files. Too big size will make it difficult to clean and shrink.
// Hence, we choose approximately 130MB (i.e. 134,217,728 bytes) for the ancient append vec size.
const RESULT: u64 = PAGE_SIZE * 32768;
const _: () = assert!(RESULT < MAXIMUM_APPEND_VEC_FILE_SIZE);
Copy link
Contributor

Choose a reason for hiding this comment

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

@HaoranYi I like this assert. The exact value is covered in the test. But, it is helpful to find the places where MAXIMUM_APPEND_VEC_FILE_SIZE is used in case of future changes by future 'us'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes. added.

@HaoranYi
Copy link
Contributor Author

This PR will require the following PR to create big ancient append vecs.

#34154

@github-actions github-actions bot added the stale [bot only] Added to stale content; results in auto-close after a week. label Dec 5, 2023
@HaoranYi
Copy link
Contributor Author

HaoranYi commented Dec 11, 2023

Now that #34154 is merged.
This PR can be merged too. Or are there any other concerns?

// 1/10 of max is a reasonable size in practice.
MAXIMUM_APPEND_VEC_FILE_SIZE / 10 - 2048
const _: () = assert!(
RESULT < MAXIMUM_APPEND_VEC_FILE_SIZE,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use <= here.

Suggested change
RESULT < MAXIMUM_APPEND_VEC_FILE_SIZE,
RESULT <= MAXIMUM_APPEND_VEC_FILE_SIZE,

(And the assert message can be tweaked slightly to say "not greater than" or equivalent.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Eh... maybe the < is better. Retracting my concern here.

Copy link
Contributor

@jeffwashington jeffwashington left a comment

Choose a reason for hiding this comment

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

lgtm

@HaoranYi HaoranYi merged commit aab12c3 into solana-labs:master Dec 11, 2023
32 checks passed
@HaoranYi HaoranYi deleted the nov_14 branch December 11, 2023 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale [bot only] Added to stale content; results in auto-close after a week.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants