Skip to content

Speed up relocation and fix bug#33608

Merged
haampie merged 1 commit intospack:developfrom
haampie:fix/speedup-binary-relocation-more
Oct 31, 2022
Merged

Speed up relocation and fix bug#33608
haampie merged 1 commit intospack:developfrom
haampie:fix/speedup-binary-relocation-more

Conversation

@haampie
Copy link
Copy Markdown
Member

@haampie haampie commented Oct 30, 2022

  • relocate_links was skipped for macOS
  • Remove the sequential filter of binaries (very slow)

LLVM before:

elf      47.34s
text      0.01s
filter   84.72s
text bin  0.003s

LLVM after:

elf      13.37s # not sure why this is so flaky...
text      0.01s
text bin  4.81s

All in all llvm installs in < 1 min, the bottleneck is decompressing the tarball now.

@spackbot-app spackbot-app bot added binary-packages core PR affects Spack core functionality labels Oct 30, 2022
Comment on lines -1655 to -1667
paths_to_relocate = [old_prefix, old_layout_root]
paths_to_relocate.extend(prefix_to_hash.keys())
files_to_relocate = list(
filter(
lambda pathname: not relocate.file_is_relocatable(
pathname, paths_to_relocate=paths_to_relocate
),
map(
lambda filename: os.path.join(workdir, filename),
buildinfo["relocate_binaries"],
),
)
)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Before we were filtering buildinfo["relocate_binaries"], so the semantic is different (not saying it was correct before). Why are we doing a lot of extra processing in relocate.file_is_relocatable? Does that processing cover some edge cases or is it plain wrong or unneeded?

Copy link
Copy Markdown
Member Author

@haampie haampie Oct 31, 2022

Choose a reason for hiding this comment

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

This can safely be dropped, currently it's horrible, and removing it makes Spack only better.

The old logic is as follows: take all strings minus the rpath from a binary (since patchelf can handle that). If among this list you find old_prefix or old_layout_root, it means this binary needs to be patched.

This is ridiculous because:

a. it's testing only two of many strings searched from the prefix_to_prefix_bin map, so it's simply incorrect;
b. it's sequential;
c. it adds a dependency on binutil's strings executable;
d. currently we only ever call binary text replacement after rpath substitution, so there's no need to special case rpaths.

Maybe in the past this filter was useful for performance reasons (calling strings is faster than scanning for strings in a binary using Python?), but clearly that's no longer true after #33590

@haampie haampie merged commit 1ab888c into spack:develop Oct 31, 2022
@haampie haampie deleted the fix/speedup-binary-relocation-more branch October 31, 2022 09:42
becker33 pushed a commit to RikkiButler20/spack that referenced this pull request Nov 2, 2022
Currently there's a slow sequential step in binary relocation where all
strings of a binary are collected, with rpaths removed, and then
filtered for the old install root.

This is completely unnecessary, and also incorrect, since we replace
more than just the old install root in the prefix to prefix mapping. And
in fact the prefix to prefix mapping is parallel, and a single pass. So
even as an optimization, this filter makes no sense anymore.

Therefor we remove it
charmoniumQ pushed a commit to charmoniumQ/spack that referenced this pull request Nov 19, 2022
Currently there's a slow sequential step in binary relocation where all
strings of a binary are collected, with rpaths removed, and then
filtered for the old install root.

This is completely unnecessary, and also incorrect, since we replace
more than just the old install root in the prefix to prefix mapping. And
in fact the prefix to prefix mapping is parallel, and a single pass. So
even as an optimization, this filter makes no sense anymore.

Therefor we remove it
@gartung
Copy link
Copy Markdown
Member

gartung commented Nov 22, 2022

@haampie thank you for fixing my bone-headed implementation.

@gartung
Copy link
Copy Markdown
Member

gartung commented Nov 22, 2022

If I recall correctly I was trying to preserve backwards compatibility.

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

Labels

binary-packages core PR affects Spack core functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants