Skip to content

Direct snapshot creation - #5061

Merged
xzfc merged 5 commits into
devfrom
direct-snapshot
Sep 12, 2024
Merged

xzfc merged 5 commits into
devfrom
direct-snapshot

Conversation

@xzfc

@xzfc xzfc commented Sep 10, 2024

Copy link
Copy Markdown
Member

This PR updates the snapshot creation logic.

Previously, the snapshot were created in two steps: (1) put files into a temporary directory, then (2) put this directory contents into an archive.

In this PR, the snapshot is written directly into an archive without an intermediate step.

Follow-up for #4943.

@timvisee timvisee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

While reviewing I did my very best to ensure both implementations are equal, but some parts are hard to track so I hope I didn't miss anything. In any case, the new implementation looks a lot better without the intermediate archive.

I did some local testing and manually compared a snapshot created with and without this PR. Both seem exactly the same to the eye in terms of contents. The snapshot created with this PR is a bit smaller. 👍

I did notice a . directory having no contents when creating a snapshot before this PR. Not quite sure why that was there.

Comment thread lib/common/common/src/tar_ext.rs Resolved
))
})?;
let shard_snapshot_path =
shard_versioning::versioned_shard_path(Path::new(""), *shard_id, 0);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm a bit confused on this empty path string, could you elaborate?

@xzfc xzfc Sep 12, 2024 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The following approach is frequently encountered in our codebase: XXX_path(base_path: &Path, YYY) is defined as base_path.join(something(YYY)).
If I need only the something(YYY) part, but not the base_path.join(…) part, I pass base_path to be an empty path, i.e. XXX_path(Path::new(""), YYY).

This includes versioned_shard_path:

pub fn versioned_shard_path(
collection_path: &Path,
shard_id: ShardId,
version: ShardVersion,
) -> PathBuf {
if version == 0 {
collection_path.join(format!("{shard_id}"))
} else {
collection_path.join(format!("{shard_id}-{version}"))
}
}

I need only {shard_id}-{version} here.

@xzfc
xzfc merged commit a640013 into dev Sep 12, 2024
@xzfc
xzfc deleted the direct-snapshot branch September 12, 2024 19:39
timvisee pushed a commit that referenced this pull request Sep 17, 2024
@timvisee timvisee mentioned this pull request Sep 17, 2024
@generall generall added this to the Sparse Snapshots milestone Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants