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

anvil: make max on disk history limit configurable #8399

Closed
Tracked by #8269
mattsse opened this issue Jul 10, 2024 · 9 comments · Fixed by #8412
Closed
Tracked by #8269

anvil: make max on disk history limit configurable #8399

mattsse opened this issue Jul 10, 2024 · 9 comments · Fixed by #8412
Assignees
Labels
C-anvil Command: anvil good first issue Good for newcomers T-feature Type: feature
Milestone

Comments

@mattsse
Copy link
Member

mattsse commented Jul 10, 2024

Component

Anvil

Describe the feature you would like

// 1hr of up-time at lowest 1s interval
const MAX_ON_DISK_HISTORY_LIMIT: usize = 3_600;

we already have this for the memory limit

min_in_memory_limit: limit.min(MIN_HISTORY_LIMIT),
max_on_disk_limit: MAX_ON_DISK_HISTORY_LIMIT,

/// Don't keep full chain history.
/// If a number argument is specified, at most this number of states is kept in memory.
#[arg(long)]
pub prune_history: Option<Option<usize>>,

maybe those can even be combined, because I think the
--prune_history is slightly confusing

So I think this should be fixed by setting

max_on_disk_limit: MAX_ON_DISK_HISTORY_LIMIT,

to limit

Additional context

No response

@qiweiii
Copy link
Contributor

qiweiii commented Jul 10, 2024

I would like to try take this

@mattsse
Copy link
Member Author

mattsse commented Jul 10, 2024

assigned,

I fixed a link above that provided relevant context:

max_on_disk_limit: MAX_ON_DISK_HISTORY_LIMIT

@zerosnacks zerosnacks added the C-anvil Command: anvil label Jul 10, 2024
@qiweiii
Copy link
Contributor

qiweiii commented Jul 11, 2024

after set it to limit, I am a bit confused by --prune_history, if user don't enable it, it uses default limit of 500, so both in memory and max disk cache length will be 500

but if user enabled it, the state will be memory only:

/// Configures no disk caching
pub fn memory_only(mut self) -> Self {
self.max_on_disk_limit = 0;

it overwrites the max_on_disk_limit set in InMemoryBlockStates::new, so setting

max_on_disk_limit: MAX_ON_DISK_HISTORY_LIMIT,

to limit has no effect, then max_on_disk_limit is still not configurable, it's default 500 or 0, maybe need a separate config for this?

@mattsse
Copy link
Member Author

mattsse commented Jul 11, 2024

ah you're right so restricting this with --prune-history doesn't have any effect actually

so this issue is kinda pointless...

@grandizzy
Copy link
Collaborator

grandizzy commented Jul 16, 2024

I think we should expose --max-persisted-states arg (or a better name, defaults to 3600 to keep current settings), to control value of InMemoryBlockStates.max_on_disk_limit that would basically make current --prune-history behavior same as --max-persisted-states=0 (and alternatively drop the --prune-history one) wdyt? @mattsse @qiweiii

@qiweiii
Copy link
Contributor

qiweiii commented Jul 16, 2024

I agree, it needs a new arg to set its value

@mattsse
Copy link
Member Author

mattsse commented Jul 16, 2024

I agree, it needs a new arg to set its value

this makes sense to me as well

@qiweiii
Copy link
Contributor

qiweiii commented Jul 18, 2024

@mattsse @grandizzy please check #8412 if this is what we want, it still feels a bit weired to have two config for in memory limit and on disk limit

@grandizzy
Copy link
Collaborator

@mattsse @grandizzy please check #8412 if this is what we want, it still feels a bit weired to have two config for in memory limit and on disk limit

thanks, I think that's OK, if I correctly understand there is only one config exposed for disk limit, that is the newly added --max-persisted-states, the memory limit is not configurable but set to const DEFAULT_HISTORY_LIMIT: usize = 500;
Maybe we can also drop the --prune-history and just add description that this can be accomplished by setting --max-persisted-states=0
@mattsse wdyt?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-anvil Command: anvil good first issue Good for newcomers T-feature Type: feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants