From 4cf538f349b21ef37d7f120918bbc5f568f2d7cb Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 7 Apr 2021 07:00:52 -0600 Subject: [PATCH] cs: compress boot files by default on Windows Compressing boot files is a trade-off in file size versus startup time. Compressed boot files take about 10MB instead of 40MB, but using uncompressed boot files cuts the minimum startup time (for `racket -n`) by around 25%. On Unix-like platforms, we favor startup time by default. Although an extra 30MB isn't small, it's also not that much, and the Unix culture favors small excutables that start quickly (although Racket's startup time is not as fast as we'd like). On Windows, we try the opposite choice with this commit. Windows doesn't have the same culture of little excutables, slower filesystems (especially networked ones) seem more common, and the savings for stand-alone executables seem more worthwhile. --- racket/src/cs/c/configure | 8 ++++++++ racket/src/cs/c/configure.ac | 8 ++++++++ racket/src/worksp/README.txt | 4 ++-- racket/src/worksp/csbuild.rkt | 36 ++++++++++++++++++++--------------- 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/racket/src/cs/c/configure b/racket/src/cs/c/configure index e126eeb446..5aeb6f849f 100755 --- a/racket/src/cs/c/configure +++ b/racket/src/cs/c/configure @@ -2830,6 +2830,7 @@ show_explicitly_disabled "${enable_pthread}" "pthreads" show_explicitly_disabled "${enable_compress}" "Compressed code" show_explicitly_disabled "${enable_compressmore}" "Compressed code even more" show_explicitly_enabled "${enable_compressboot}" "Compressed boot files" +show_explicitly_disabled "${enable_compressboot}" "Compressed boot files" show_explicitly_enabled "${enable_xonx}" "Unix style" show_explicitly_enabled "${enable_libzo}" 'Compiled ".zo" files moved to lib' @@ -3247,6 +3248,8 @@ PLT_CS_SLSP_SUFFIX= enable_pthread_by_default=yes +compress_boot_files_by_default=no + cs_auto_flags=--disable-auto-flags ###### Autoconfigure ####### @@ -4392,6 +4395,7 @@ case "$host_os" in LIBS="${LIBS} -lshell32 -luser32 -lole32 -lrpcrt4 -luuid -lws2_32 -ladvapi32 -lwinmm" MINGW="" NOT_MINGW="mingw" + compress_boot_files_by_default=yes if `which ${host}-windres > /dev/null` ; then WINDRES="${host}-windres" fi @@ -4691,6 +4695,10 @@ fi if test "${enable_compressboot}" = "yes" ; then BOOT_COMPRESS_COMP="--compress" +elif test "${compress_boot_files_by_default}" = "yes" ; then + if test "${enable_compressboot}" != "no" ; then + BOOT_COMPRESS_COMP="--compress" + fi fi DIFF_MACH=skip diff --git a/racket/src/cs/c/configure.ac b/racket/src/cs/c/configure.ac index 13b16ba2b0..e8e67fc8c2 100644 --- a/racket/src/cs/c/configure.ac +++ b/racket/src/cs/c/configure.ac @@ -75,6 +75,7 @@ show_explicitly_disabled "${enable_pthread}" "pthreads" show_explicitly_disabled "${enable_compress}" "Compressed code" show_explicitly_disabled "${enable_compressmore}" "Compressed code even more" show_explicitly_enabled "${enable_compressboot}" "Compressed boot files" +show_explicitly_disabled "${enable_compressboot}" "Compressed boot files" show_explicitly_enabled "${enable_xonx}" "Unix style" m4_include(../ac/path_show.m4) show_explicitly_set "${enable_racket}" "Racket" @@ -166,6 +167,8 @@ PLT_CS_SLSP_SUFFIX= enable_pthread_by_default=yes +compress_boot_files_by_default=no + cs_auto_flags=--disable-auto-flags ###### Autoconfigure ####### @@ -275,6 +278,7 @@ case "$host_os" in LIBS="${LIBS} -lshell32 -luser32 -lole32 -lrpcrt4 -luuid -lws2_32 -ladvapi32 -lwinmm" MINGW="" NOT_MINGW="mingw" + compress_boot_files_by_default=yes if `which ${host}-windres > /dev/null` ; then WINDRES="${host}-windres" fi @@ -497,6 +501,10 @@ fi if test "${enable_compressboot}" = "yes" ; then BOOT_COMPRESS_COMP="--compress" +elif test "${compress_boot_files_by_default}" = "yes" ; then + if test "${enable_compressboot}" != "no" ; then + BOOT_COMPRESS_COMP="--compress" + fi fi DIFF_MACH=skip diff --git a/racket/src/worksp/README.txt b/racket/src/worksp/README.txt index 2650173ba7..1ce24b1a98 100644 --- a/racket/src/worksp/README.txt +++ b/racket/src/worksp/README.txt @@ -50,8 +50,8 @@ Many intermediate files will be put in "../build". To add a "CS" suffix to the generated executables, call "csbuild.rkt" with `--racketcs-suffix "CS"`. -To enable compression of embedded boot files, set the -`PLT_BOOTFILE_COMPRESS` environment variable (to anything). To +To disable compression of embedded boot files, set the +`PLT_BOOTFILE_NO_COMPRESS` environment variable (to anything). To increase compression of compiled code (at the expense of load times), set the `PLT_CS_MAKE_COMPRESSED_DATA`. To instead disable the compression of compiled code, set `PLT_CS_MAKE_NO_COMPRESSED`. diff --git a/racket/src/worksp/csbuild.rkt b/racket/src/worksp/csbuild.rkt index 52a0ba8f68..279d912fef 100644 --- a/racket/src/worksp/csbuild.rkt +++ b/racket/src/worksp/csbuild.rkt @@ -9,7 +9,7 @@ "cs/recompile.rkt") ;; Environment variables that affect the build: -;; PLT_BOOTFILE_COMPRESS - enables compression of boot files +;; PLT_BOOTFILE_NO_COMPRESS - disables compression of boot files ;; PLT_CS_MAKE_COMPRESSED_DATA - enables more ".zo" compression ;; PLT_CS_MAKE_NO_COMPRESSED - disables default ".zo" compression @@ -47,7 +47,11 @@ (current-directory here) -(define (system*! prog . args) +;; filters #f from arguments +(define (system*! prog . all-args) + (define args (for/list ([arg (in-list all-args)] + #:when arg) + arg)) (printf "{in ~a}\n" (current-directory)) (printf "~a" prog) (for ([arg (in-list args)]) @@ -190,6 +194,10 @@ ;; ---------------------------------------- +(define compress-flag + (and (not (getenv "PLT_BOOTFILE_NO_COMPRESS")) + "--compress")) + (system*! scheme "--script" "../cs/c/convert-to-boot.ss" @@ -200,12 +208,14 @@ (system*! scheme "--script" "../cs/c/to-vfasl.ss" + compress-flag (build-path scheme-dir machine "boot" machine "petite.boot") "../build/petite-v.boot") (system*! scheme "--script" "../cs/c/to-vfasl.ss" + compress-flag (build-path scheme-dir machine "boot" machine "scheme.boot") "../build/scheme-v.boot" "petite") @@ -213,6 +223,7 @@ (system*! scheme "--script" "../cs/c/to-vfasl.ss" + compress-flag "../build/racket.boot" "../build/racket-v.boot" "petite" @@ -226,19 +237,14 @@ args)) (make-directory* "../../lib") -(apply bootstrap-racket! - "../cs/c/embed-boot.rkt" - (append - (if (getenv "PLT_BOOTFILE_COMPRESS") - '("--compress") - '()) - (list - "++exe" "../build/raw_racketcs.exe" (format "../../Racket~a.exe" cs-suffix) - "++exe" "../build/raw_gracketcs.exe" (format "../../lib/GRacket~a.exe" cs-suffix) - "../build/raw_libracketcs.dll" "../../lib/libracketcsxxxxxxx.dll" - "../build/petite-v.boot" - "../build/scheme-v.boot" - "../build/racket-v.boot"))) +(bootstrap-racket! "../cs/c/embed-boot.rkt" + compress-flag + "++exe" "../build/raw_racketcs.exe" (format "../../Racket~a.exe" cs-suffix) + "++exe" "../build/raw_gracketcs.exe" (format "../../lib/GRacket~a.exe" cs-suffix) + "../build/raw_libracketcs.dll" "../../lib/libracketcsxxxxxxx.dll" + "../build/petite-v.boot" + "../build/scheme-v.boot" + "../build/racket-v.boot") (system*! "mt" "-manifest" "racket/racket.manifest"