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

Use multi-core optimized pgzip package in tarball compressor #98

Merged
merged 4 commits into from
Oct 17, 2024
Merged

Conversation

rkoster
Copy link
Contributor

@rkoster rkoster commented Oct 16, 2024

Some early benchmarks (when using these changes in the bosh-cli):

time bosh create-release --dir ~/workspace/carvel-on-bosh-demo/release --force --tarball=/tmp/slow.tgz
# 5.69s user 0.66s system 96% cpu 6.569 total
time ./out/bosh create-release --dir ~/workspace/carvel-on-bosh-demo/release --force --tarball=/tmp/fast.tgz
# 1.11s user 0.53s system 105% cpu 1.556 total

I did make this a breaking change to the interface because we no longer need the CmdRunner in the TarballCompressor.

@rkoster rkoster requested review from a team, ystros, lnguyen, beyhan and jpalermo and removed request for a team October 16, 2024 08:35
@rkoster rkoster changed the base branch from master to develop October 16, 2024 11:21
return bosherr.WrapError(err, "Decompressing file contents")
}
default:
return fmt.Errorf("uknown type: %v in %s for tar: %s",
Copy link
Contributor

Choose a reason for hiding this comment

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

Slight typo for unknown

"path/filepath"

"archive/tar"
gzip "github.com/klauspost/pgzip"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe drop this import alias? It only hides information.

Copy link
Member

@beyhan beyhan left a comment

Choose a reason for hiding this comment

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

Is the pgzip library actively maintained? I was checking the activity in the repository and there were not much since two years. It could be that there was no need for any updates because it only adds parallel execution.

}

if fi.Mode().IsRegular() {
data, err := os.Open(f)
Copy link
Member

Choose a reason for hiding this comment

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

should this opened file be closed or is handled by the close of the tarball defer tarball.Close()?

Comment on lines 101 to 106
tarball, err := c.fs.OpenFile(tarballPath, os.O_RDONLY, 0)
if err != nil {
return bosherr.WrapError(err, "Opening tarball")
}

if options.PathInArchive != "" {
args = append(args, options.PathInArchive)
}
_, _, _, err := c.cmdRunner.RunCommand("tar", args...)
zr, err := gzip.NewReader(tarball)
Copy link
Member

Choose a reason for hiding this comment

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

Should we add defer tarball.Close() and defer zr.Close()? The CompressFilesInDir function is closing the tarball stream e.g.. Or is the close handled differently here because I couldn't follow where the close is happening?

@rkoster
Copy link
Contributor Author

rkoster commented Oct 17, 2024

Is the pgzip library actively maintained? I was checking the activity in the repository and there were not much since two years. It could be that there was no need for any updates because it only adds parallel execution.

The maintainer is still active on issues (the most recent one is from February): klauspost/pgzip#56 (comment)

So to me that suggests the project is feature-complete. It also has a healthy number of github stars.

@rkoster rkoster requested a review from beyhan October 17, 2024 08:21
- don't use import alias
- close all readers / writers
- fix typo
- also use bosh filesystem interface when reading file contents
@rkoster rkoster merged commit 9bf35b5 into develop Oct 17, 2024
5 checks passed
@rkoster rkoster deleted the pgzip branch October 17, 2024 08:41
@beyhan
Copy link
Member

beyhan commented Oct 17, 2024

Waiting for #99

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

4 participants