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

[WIP] Faster rpm build #436

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

jrafanie
Copy link
Member

@jrafanie jrafanie commented Jan 9, 2024

Here are some very WIP small and larger changes to try to speed up the rpm build.

My plan is to extract things we like and get them in.

  • disable pythondeps - wastes 45 minutes locally... not sure if we need it, and definitely shouldn't be changing all that often. We can possibly run this once per major change.
  • final commit is just debug logging output

EDIT:
Extracted to #437

  • .build-id artifacts - To extract, pretty minor... tens of files are eliminated from the tarballs
  • use built-in vcs to catch .git, .gitignore and friends instead of hardcoded list - seems safe to extract and it's super minor
  • faster brp-strip... was 33 minutes... now around 2. Uses new version of the file.

This was externalized in subsequent versions of rpmbuild: rpm-software-management/rpm#1607

I believe we can manually run this if needed to build any python provides, requires, etc. whenever we pull in new python stuff.
@miq-bot miq-bot added the wip label Jan 9, 2024
@Fryguy
Copy link
Member

Fryguy commented Jan 9, 2024

Another option might be to just install rpmbuild 4.19 directly to avoid the curl and os macro changes. Not sure how hard that is or not

@@ -22,14 +33,14 @@ def create_gemset_tarball
plugin_index.write(plugin_index.read.gsub(BUILD_DIR.join("manageiq").to_s, '/var/www/miq/vmdb'))

name = "gemset"
shell_cmd("tar -C #{BUILD_DIR} -zcf #{tar_full_path(name)} -X #{exclude_file(name)} #{tar_basename(name)}")
shell_cmd("tar -C #{BUILD_DIR} -zcf #{tar_full_path(name)} --exclude-vcs -X #{exclude_file(name)} #{tar_basename(name)}")
Copy link
Member

Choose a reason for hiding this comment

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

This could be a problem if it removes more than the .git dir from git based gems within bundler (well have to check if that matters or not, and it's possible we already had those removed)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. I really want to see if I can run rpmdiff before and after this PR. I will not extract that until I can do that.

@@ -0,0 +1,50 @@
#!/bin/sh
# From https://github.com/rpm-software-management/rpm/blob/rpm-4.19.1-release/scripts/brp-strip
Copy link
Member

Choose a reason for hiding this comment

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

As discussed, since this is a GPL file let's try curl and patch instead

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I think it's similar to pulling down the source for repmgr in https://github.com/ManageIQ/manageiq-rpm_build/blob/master/packages/repmgr13/repmgr.spec#L24. Then, we just have patch file with the minor change to add rb/js filtering and we can apply that on top.

@jrafanie
Copy link
Member Author

jrafanie commented Jan 9, 2024

Another option might be to just install rpmbuild 4.19 directly to avoid the curl and os macro changes. Not sure how hard that is or not

My assumption is we'd need to add a new dnf repo to install it as it will likely pull in lots of other dependencies. We're using the latest rpm/rpmbuild available in our ubi8 repo.

@Fryguy
Copy link
Member

Fryguy commented Jan 9, 2024

We also discussed a possible rm -rf of all python test directories. While that might not change much since disabling pythondeps is the bigger change, it might have other benefits, such as

  • Smaller RPM files
  • Even less to traverse as part of brp-strip
  • Removing files that are subject to license auditing (I actually get these frequently because some test suites have copies of GPL files within them)

Dockerfile Outdated
Comment on lines 68 to 76
RUN curl -o brp-strip https://raw.githubusercontent.com/rpm-software-management/rpm/rpm-4.19.1-release/scripts/brp-strip

RUN chmod +x brp-strip

RUN patch -p2 < Add-js-rb-filtering-on-top-of-4.19.1.patch && \
ls -l /usr/lib/rpm/brp-strip && \
mv brp-strip /usr/lib/rpm/brp-strip && \
ls -l /usr/lib/rpm/brp-strip && \
rm -f Add-js-rb-filtering-on-top-of-4.19.1.patch
Copy link
Member

@Fryguy Fryguy Jan 9, 2024

Choose a reason for hiding this comment

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

Nice! A few comments here:

  • The patch file should probably live in the container-assets directory, as opposed to the root. That way you can reuse the COPY . /build_scripts command which already copies the container-assets directory.
  • Prefer curling the file directly into /usr/lib/rpm/brp-strip, overwriting it, and then patching /usr/lib/rpm/brp-strip directly.
  • No need to remove the patch file (it doesn't really get deleted from the container anyway)
  • Smash all of the RUN commands into a single line.

@miq-bot
Copy link
Member

miq-bot commented Jan 9, 2024

Some comments on commits jrafanie/manageiq-rpm_build@215db4c~...79931aa

lib/manageiq/rpm_build/generate_tar_files.rb

  • ⚠️ - 11 - Detected puts. Remove all debugging statements.
  • ⚠️ - 13 - Detected puts. Remove all debugging statements.
  • ⚠️ - 15 - Detected puts. Remove all debugging statements.
  • ⚠️ - 17 - Detected puts. Remove all debugging statements.
  • ⚠️ - 19 - Detected puts. Remove all debugging statements.
  • ⚠️ - 21 - Detected puts. Remove all debugging statements.
  • ⚠️ - 23 - Detected puts. Remove all debugging statements.
  • ⚠️ - 25 - Detected puts. Remove all debugging statements.

@miq-bot
Copy link
Member

miq-bot commented Jan 9, 2024

Checked commits jrafanie/manageiq-rpm_build@215db4c~...79931aa with ruby 2.7.8, rubocop 1.56.3, haml-lint 0.51.0, and yamllint
3 files checked, 9 offenses detected

lib/manageiq/rpm_build/generate_tar_files.rb

Comment on lines +66 to +74
RUN curl -o /usr/lib/rpm/brp-strip https://raw.githubusercontent.com/rpm-software-management/rpm/rpm-4.19.1-release/scripts/brp-strip

RUN chmod +x /usr/lib/rpm/brp-strip

COPY . /build_scripts

RUN cd /usr/lib/rpm/ && \
patch -p2 < /build_scripts/container-assets/Add-js-rb-filtering-on-top-of-4.19.1.patch

Copy link
Member

Choose a reason for hiding this comment

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

You can still smash all these together further

Suggested change
RUN curl -o /usr/lib/rpm/brp-strip https://raw.githubusercontent.com/rpm-software-management/rpm/rpm-4.19.1-release/scripts/brp-strip
RUN chmod +x /usr/lib/rpm/brp-strip
COPY . /build_scripts
RUN cd /usr/lib/rpm/ && \
patch -p2 < /build_scripts/container-assets/Add-js-rb-filtering-on-top-of-4.19.1.patch
COPY . /build_scripts
RUN curl -o /usr/lib/rpm/brp-strip https://raw.githubusercontent.com/rpm-software-management/rpm/rpm-4.19.1-release/scripts/brp-strip && \
chmod +x /usr/lib/rpm/brp-strip && \
cd /usr/lib/rpm/ && \
patch -p2 < /build_scripts/container-assets/Add-js-rb-filtering-on-top-of-4.19.1.patch

@jrafanie jrafanie mentioned this pull request Jan 10, 2024
@miq-bot
Copy link
Member

miq-bot commented Jan 18, 2024

This pull request is not mergeable. Please rebase and repush.

@Fryguy
Copy link
Member

Fryguy commented Jan 18, 2024

Merged #437, so this needs a rebase.

@miq-bot miq-bot added the stale label Apr 22, 2024
@miq-bot
Copy link
Member

miq-bot commented Apr 22, 2024

This pull request has been automatically marked as stale because it has not been updated for at least 3 months.

If these changes are still valid, please remove the stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s).

1 similar comment
@miq-bot
Copy link
Member

miq-bot commented Jul 29, 2024

This pull request has been automatically marked as stale because it has not been updated for at least 3 months.

If these changes are still valid, please remove the stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s).

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

Successfully merging this pull request may close these issues.

3 participants