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

Segment headers store #1692

Merged
merged 7 commits into from
Jul 26, 2023
Merged

Segment headers store #1692

merged 7 commits into from
Jul 26, 2023

Conversation

nazar-pc
Copy link
Member

This implements global persistent segment headers store (with in-memory cache) in node and replaces a few different stores we used before this.

Implementation will be extended in the future, in particular it will be possible to store sequences of segment headers in the same entry (not implemented, but there is TODO for this that I called compaction) to reduce fragmentation as well as populate segment headers store initially when syncing from DSN (in which case we'll have to check that segment headers are written sequentially, there is TODO about this as well).

Data stored on disk changes in this PR, hence breaking label.

Resolves #1125

Code contributor checklist:

@nazar-pc nazar-pc added the breaking-node This PR introduces breaking changes to the node implementation label Jul 25, 2023
Copy link
Member

@shamil-gadelshin shamil-gadelshin left a comment

Choose a reason for hiding this comment

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

I got a couple of questions about ever-growing memory and cache loading times. Also, I would like to see debug messages in methods that have a chance to fail (like disk IO).

let insert_data = vec![(key.as_slice(), value.as_slice())];

self.inner.aux_store.insert_aux(&insert_data, &[])?;
self.inner.cache.lock().extend_from_slice(segment_headers);
Copy link
Member

Choose a reason for hiding this comment

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

Does it mean ever-growing memory usage? How do you estimate memory usage during the network life?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it is estimated to be less than 1 GiB for 1 PiB of pieces, so should not be an issue for a very long time. We can always switch to loading data from disk, but it is much better to have in-memory cache.

crates/sc-consensus-subspace/src/archiver.rs Show resolved Hide resolved
Copy link
Member Author

@nazar-pc nazar-pc left a comment

Choose a reason for hiding this comment

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

Also, I would like to see debug messages in methods that have a chance to fail (like disk IO).

There are already errors returned already and they are logged at call site, is there something else you have in mind?

let insert_data = vec![(key.as_slice(), value.as_slice())];

self.inner.aux_store.insert_aux(&insert_data, &[])?;
self.inner.cache.lock().extend_from_slice(segment_headers);
Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it is estimated to be less than 1 GiB for 1 PiB of pieces, so should not be an issue for a very long time. We can always switch to loading data from disk, but it is much better to have in-memory cache.

Copy link
Member

@shamil-gadelshin shamil-gadelshin left a comment

Choose a reason for hiding this comment

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

There are already errors returned already and they are logged at call site, is there something else you have in mind?

That will be enough for this PR. Consider adding more logging for complex code using trace or debug log levels in the future. It could be easier to understand what is going on in the app when debugging.

@nazar-pc nazar-pc merged commit 1e12a6e into main Jul 26, 2023
@nazar-pc nazar-pc deleted the segment-headers-store branch July 26, 2023 11:12
@nazar-pc nazar-pc mentioned this pull request Jul 31, 2023
1 task
ParthDesai added a commit to autonomys/subspace-pulsar-sdk that referenced this pull request Aug 4, 2023
ParthDesai added a commit to autonomys/subspace-pulsar-sdk that referenced this pull request Aug 15, 2023
ParthDesai added a commit to autonomys/subspace-pulsar-sdk that referenced this pull request Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-node This PR introduces breaking changes to the node implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor record roots and root blocks storage.
2 participants