mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-07 15:51:08 +00:00
Speed up the Linux image build
Profiling build_linux_image.sh: 96 s, of which 51 s in the dependency audit.
appimage_is_elf_file() ran file(1) and grep per candidate. An AppDir holds ~9.6k
of them, 4.8k being the bundled Python runtime, none of them ELF: ~19k processes
for 14 s. Read the four-byte magic instead; checked against the old result on
4000 files, no disagreement.
The dependency walk popped its queue with "${queue[@]:1}", which rebuilds the
whole array each time. At ~4.8k entries that was 22 s of copying. Use a read
index.
96 s -> 12.7 s. The audit still passes.
This commit is contained in:
@@ -23,7 +23,13 @@ appimage_is_host_library() {
|
||||
}
|
||||
|
||||
appimage_is_elf_file() {
|
||||
file -b "$1" 2>/dev/null | grep -q '^ELF '
|
||||
# Read the four-byte ELF magic rather than asking file(1): this runs once per candidate, and an
|
||||
# AppDir holds thousands of them (the bundled Python runtime alone is ~5k files, none of them
|
||||
# ELF). Two processes per call made this ~14 s of a ~95 s image build on its own.
|
||||
local magic
|
||||
[[ -f "$1" && -r "$1" ]] || return 1
|
||||
IFS= read -r -n 4 -d '' magic < "$1" 2>/dev/null
|
||||
[[ $magic == $'\177ELF' ]]
|
||||
}
|
||||
|
||||
appimage_list_direct_dependencies() {
|
||||
|
||||
Reference in New Issue
Block a user