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

profiles: slsa: Remove quadratic complexity in SRC_URI iteration #1399

Closed
wants to merge 1 commit into from

Conversation

jepio
Copy link
Member

@jepio jepio commented Nov 17, 2023

speed up slsa provenance generation for some packages

SLSA provenance generation iterates over $A (which is a subset of $SRC_URI) and for each of those tries to find a match in $SRC_URI. That's quadratic complexity, and the performance impact is bad because we shell out to a helper utility (basename) for every entry. This is leading to long stalls when generating SLSA for packages with long distfile lists, like go and rust packages. Iterate over SRC_URI once and create a dictionary to speed up subsequent lookups. dev-db/etcdctl is a good candidate for testing.

How to use

time emerge-amd64-usr etcdtctl

Testing done

Before: >10min on my laptop
After: 1min on my laptop (includes build time)

[Describe the testing you have done before submitting this PR. Please include both the commands you issued as well as the output you got.]

  • Changelog entries added in the respective changelog/ directory (user-facing change, bug fix, security fix, update)
  • Inspected CI output for image differences: /boot and /usr size, packages, list files for any missing binaries, kernel modules, config files, kernel modules, etc.

SLSA provenance generation iterates over $A (which is a subset of $SRC_URI) and
for each of those tries to find a match in $SRC_URI. That's quadratic
complexity, and the performance impact is bad because we shell out to a helper
utility (basename) for every entry. This is leading to long stalls when
generating SLSA for packages with long distfile lists, like go and rust
packages. Iterate over SRC_URI once and create a dictionary to speed up
subsequent lookups. dev-db/etcdctl is a good candidate for testing.

Signed-off-by: Jeremi Piotrowski <[email protected]>
@jepio jepio requested review from t-lo and krnowak November 17, 2023 12:10
Copy link
Member

@krnowak krnowak left a comment

Choose a reason for hiding this comment

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

Looks good. You probably could drop the found variable now, but I have updated the whole SLSA thing in #1157, so I can do it in the PR.

Copy link

github-actions bot commented Nov 17, 2023

@jepio
Copy link
Member Author

jepio commented Nov 20, 2023

@krnowak lets cherry-pick this into your PR then

@krnowak
Copy link
Member

krnowak commented Dec 6, 2023

Cherry picked to #1157.

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