use gzip for runner embedding (#2067)

This commit is contained in:
Jeffrey Morgan 2024-01-19 13:23:03 -05:00 committed by GitHub
parent 62976087c6
commit dc88cc3981
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 13 deletions

View file

@ -84,7 +84,7 @@ compress_libs() {
echo "Compressing payloads to reduce overall binary size..." echo "Compressing payloads to reduce overall binary size..."
pids="" pids=""
for lib in ${BUILD_DIR}/lib/*.${LIB_EXT}* ; do for lib in ${BUILD_DIR}/lib/*.${LIB_EXT}* ; do
bzip2 -v9 ${lib} & gzip --best ${lib} &
pids+=" $!" pids+=" $!"
done done
echo echo

View file

@ -23,7 +23,7 @@ function init_vars {
} else { } else {
$script:CUDA_LIB_DIR=$env:CUDA_LIB_DIR $script:CUDA_LIB_DIR=$env:CUDA_LIB_DIR
} }
$script:BZIP2=(get-command -ea 'silentlycontinue' bzip2).path $script:GZIP=(get-command -ea 'silentlycontinue' gzip).path
$script:DUMPBIN=(get-command -ea 'silentlycontinue' dumpbin).path $script:DUMPBIN=(get-command -ea 'silentlycontinue' dumpbin).path
} }
@ -69,14 +69,14 @@ function install {
} }
function compress_libs { function compress_libs {
if ($script:BZIP2 -eq $null) { if ($script:GZIP -eq $null) {
write-host "bzip2 not installed, not compressing files" write-host "gzip not installed, not compressing files"
return return
} }
write-host "Compressing dlls..." write-host "Compressing dlls..."
$libs = dir "${script:buildDir}/lib/*.dll" $libs = dir "${script:buildDir}/lib/*.dll"
foreach ($file in $libs) { foreach ($file in $libs) {
& "$script:BZIP2" -v9 $file & "$script:GZIP" --best $file
} }
} }

View file

@ -1,7 +1,7 @@
package llm package llm
import ( import (
"compress/bzip2" "compress/gzip"
"errors" "errors"
"fmt" "fmt"
"io" "io"
@ -182,9 +182,12 @@ func extractDynamicLibs(workDir, glob string) ([]string, error) {
} }
src := io.Reader(srcFile) src := io.Reader(srcFile)
filename := file filename := file
if strings.HasSuffix(file, ".bz2") { if strings.HasSuffix(file, ".gz") {
src = bzip2.NewReader(src) src, err = gzip.NewReader(src)
filename = strings.TrimSuffix(filename, ".bz2") if err != nil {
return fmt.Errorf("decompress payload %s: %v", file, err)
}
filename = strings.TrimSuffix(filename, ".gz")
} }
destFile := filepath.Join(targetDir, filepath.Base(filename)) destFile := filepath.Join(targetDir, filepath.Base(filename))
@ -229,9 +232,12 @@ func extractPayloadFiles(workDir, glob string) error {
} }
src := io.Reader(srcFile) src := io.Reader(srcFile)
filename := file filename := file
if strings.HasSuffix(file, ".bz2") { if strings.HasSuffix(file, ".gz") {
src = bzip2.NewReader(src) src, err = gzip.NewReader(src)
filename = strings.TrimSuffix(filename, ".bz2") if err != nil {
return fmt.Errorf("decompress payload %s: %v", file, err)
}
filename = strings.TrimSuffix(filename, ".gz")
} }
destFile := filepath.Join(workDir, filepath.Base(filename)) destFile := filepath.Join(workDir, filepath.Base(filename))

View file

@ -28,7 +28,6 @@ fi
if [ -n "${CMAKE_VERSION}" ]; then if [ -n "${CMAKE_VERSION}" ]; then
curl -s -L https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-$(uname -m).tar.gz | tar -zx -C /usr --strip-components 1 curl -s -L https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-$(uname -m).tar.gz | tar -zx -C /usr --strip-components 1
dnf install -y bzip2
fi fi
if [ -n "${GOLANG_VERSION}" ]; then if [ -n "${GOLANG_VERSION}" ]; then