Skip to content

Switch to using hubtools for some hubris archive manipulation#633

Open
labbott wants to merge 2 commits intomasterfrom
hubtools
Open

Switch to using hubtools for some hubris archive manipulation#633
labbott wants to merge 2 commits intomasterfrom
hubtools

Conversation

@labbott
Copy link
Copy Markdown
Contributor

@labbott labbott commented Apr 27, 2026

When humility/hubris were first developed we didn't have many details of the hubris archive beyond "it's a zip". We've since developed a separate library for hubris manipulation. Let humility use it too.

Comment on lines -641 to -648
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum HubrisArchiveDoneness {
/// Fully load archive
Cook,
/// Load archive into memory, but do not otherwise process
Raw,
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Getting rid of this works fine but it makes the CI tests take longer, probably because they now have to do the full hubris archive load for extract. I think I'm going to bring this back and fix extract instead.

@labbott labbott force-pushed the hubtools branch 2 times, most recently from c4c3a45 to a871a18 Compare April 29, 2026 14:25
Early hubris archives were tagged with version v1.0.0. Newer
versions are a single integer. Rather than hack around this
in the version parsing, just remove the old cores.
Comment on lines +1400 to +1407
let mut objects = (0..hubris.file_count()?)
.into_par_iter()
.map(|i| -> Result<Option<(usize, String, Vec<u8>)>> {
// ZipArchive is cheap to clone since the backing is cheap
let mut archive = archive.clone();
let mut file = archive.by_index(i)?;
let path = Path::new(file.name());
let archive = hubris.clone();

let (name, data) = archive.extract_file_by_index(i)?;
let path = Path::new(&name);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I wrote some of this code a few years ago but had a cryptic commit message about it being too slow. If I had to guess it was this code which was too slow (maybe before we even had parallel iteration) but we basically match mainline if we let the archive be cloneable oxidecomputer/hubtools#63

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Following up on my comments from the hubtools PR, I don't think the cloning is necessary here:

Suggested change
let mut objects = (0..hubris.file_count()?)
.into_par_iter()
.map(|i| -> Result<Option<(usize, String, Vec<u8>)>> {
// ZipArchive is cheap to clone since the backing is cheap
let mut archive = archive.clone();
let mut file = archive.by_index(i)?;
let path = Path::new(file.name());
let archive = hubris.clone();
let (name, data) = archive.extract_file_by_index(i)?;
let path = Path::new(&name);
let mut objects = (0..hubris.file_count()?)
.into_par_iter()
.map(|i| -> Result<Option<(usize, String, Vec<u8>)>> {
let (name, data) = hubris.extract_file_by_index(i)?;
let path = Path::new(&name);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ahhhh I see now that there were mutable shenanigans going on with the ZipArchive but that's not the case here.

Comment on lines +1508 to +1511
let archive = RawHubrisArchive::from_vec(hubris.zip.clone())?;

// ZipArchive is cheap to clone since the backing is cheap
let (name, data) = archive.extract_file_by_index(i)?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Similarly,

Suggested change
let archive = RawHubrisArchive::from_vec(hubris.zip.clone())?;
// ZipArchive is cheap to clone since the backing is cheap
let (name, data) = archive.extract_file_by_index(i)?;
let (name, data) = hubris.extract_file_by_index(i)?;

When humility/hubris were first developed we didn't have many
details of the hubris archive beyond "it's a zip". We've since
developed a separate library for hubris manipulation. Let
humility use it too.
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.

2 participants