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

Add support for multiple attestations at once #76

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

jonjohnsonjr
Copy link
Collaborator

@jonjohnsonjr jonjohnsonjr commented Sep 19, 2023

We should bikeshed exact format and names here.

Combined with: chainguard-dev/terraform-publisher-apko#18

I instrumented terraform output how long each WriteState invocation took, then ran a few things locally before and after.

terraform apply -auto-approve -target=module.go

With just a single module, things look not that different...

Total WriteState latency: 5.7s -> 4.185s (~27% drop)

Number of WriteState calls: 344 -> 260 (~24% drop)

But if we pull in some more modules:

terraform apply -auto-approve -target=module.go -target=module.dotnet -target=module.python -target=module.python-fips -target=module.go-fips

Total WriteState latency: 50s -> 33s (~34% drop)

Number of WriteState calls: 1078 -> 796 (~26% drop)

If we look plot each point (milliseconds), we see something like this:

image

The latency for each WriteState grows ~linearly with the the size of the terraform.tfstate file, which is proportional to the number of resources, so the overall latency will grow quadratically.

Terraform also allocates two new buffer that end up growing to be the size of the terraform.tfstate file (and the previous file), so this also starts to cause a lot of GC pressure as the size increases.

@jonjohnsonjr jonjohnsonjr force-pushed the attestations branch 3 times, most recently from 5b7ff50 to af35517 Compare September 19, 2023 21:55
@mattmoor
Copy link
Member

I think we're leaving ~3x on the table by not enabling attesting to multiple images simultaneously.

This is still going to be ~3x the WriteState volume as cosign_sign simply because we can't recursively attest (because we want to specialize the attestation body per architecture).

I'd be fine with adding this, but similar to wanting a form of oci_tag that accepts digest -> []tag, I think we want something like digest -> []statement here.

@mattmoor
Copy link
Member

I think I'd call the above resources something different cosign_multi_attest or oci_multi_tag?

So I'd be fine with landing this as-is and trying to measure the impact of this on our mega module 🤞

Signed-off-by: Jon Johnson <jon.johnson@chainguard.dev>
@jonjohnsonjr jonjohnsonjr marked this pull request as ready for review September 20, 2023 20:26
@jonjohnsonjr
Copy link
Collaborator Author

So I'd be fine with landing this as-is and trying to measure the impact of this on our mega module

SGTM -- collapsing at this level is nice because we get both fewer resources but also fewer HTTP requests to the registry (we do the whole .att tag at once), so this should make a nice dent.

Agree with adding a new resource if we want to collapse multiple archs/index into a single resource.

@jonjohnsonjr jonjohnsonjr merged commit 4769c9e into chainguard-dev:main Sep 20, 2023
@mattmoor
Copy link
Member

@jonjohnsonjr yeah, I also think it would be neat to consider having this "set" the attestations vs. augment them. Or at least have an option to strip ~other attestations of the same predicate type, so it doesn't grow monotonically.

@jonjohnsonjr jonjohnsonjr deleted the attestations branch September 20, 2023 23:10
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