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

[FEATURE] Create ztoc in a single pass #1272

Open
Kern-- opened this issue Jun 7, 2024 · 0 comments
Open

[FEATURE] Create ztoc in a single pass #1272

Kern-- opened this issue Jun 7, 2024 · 0 comments
Labels
feature New feature or request

Comments

@Kern--
Copy link
Contributor

Kern-- commented Jun 7, 2024

Description

The current implementation of ZTOC building first creates zinfo from the layer file, then creates a toc from the file:

compressionInfo, fs, err := b.zinfoBuilders[opt.algorithm].ZinfoFromFile(filename, span)
if err != nil {
return nil, err
}
toc, uncompressedArchiveSize, err := b.tocBuilder.TocFromFile(opt.algorithm, filename)
if err != nil {
return nil, err
}

The implentation of Zinfo building first creates the Zinfo from the layer file, then gets span digests from the file.

index, err := compression.NewZinfoFromFile(compression.Gzip, filename, spanSize)
if err != nil {
return
}
defer index.Close()
fs, err = getFileSize(filename)
if err != nil {
return
}
digests, err := getPerSpanDigests(filename, int64(fs), index)
if err != nil {
return
}

The full path for compressed layers is:

  1. Read and decompress the layer file to create zinfo
  2. Read the compressed layer file to create span digests
  3. Read and decompress the layer file to create the TOC

We read the file 3 times and decompress it 2 times.

Describe the solution you'd like

We should be able to do this in a streaming context:

  1. Read the file, decompress it to create the zinfo and span digests at the same time
  2. Use the decompressed stream to create the TOC

That way we should be able to read the file once, decompress once, and read the uncompressed stream once.

Describe any alternative solutions/features you've considered

No response

Any additional context or information about the feature request

Related to:
#366
#76

@Kern-- Kern-- added the feature New feature or request label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant