Skip to content

Commit 0ee175b

Browse files
committed
Add --compress-sysimage flag; use zstd-15 when enabled
1 parent c345e73 commit 0ee175b

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

base/options.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct JLOptions
6767
task_metrics::Int8
6868
timeout_for_safepoint_straggler_s::Int16
6969
gc_sweep_always_full::Int8
70+
compress_sysimage::Int8
7071
end
7172

7273
# This runs early in the sysimage != is not defined yet

base/util.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ function julia_cmd(julia=joinpath(Sys.BINDIR, julia_exename()); cpu_target::Unio
245245
if opts.use_sysimage_native_code == 0
246246
push!(addflags, "--sysimage-native-code=no")
247247
end
248+
if opts.compress_sysimage == 1
249+
push!(addflags, "--compress-sysimage=yes")
250+
end
248251
return `$julia -C $cpu_target -J$image_file $addflags`
249252
end
250253

src/aotcompile.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,8 +2149,7 @@ void jl_dump_native_impl(void *native_code,
21492149
sysimgM.setStackProtectorGuard(StackProtectorGuard);
21502150
sysimgM.setOverrideStackAlignment(OverrideStackAlignment);
21512151

2152-
char *compression_str = getenv("JULIA_IMAGE_COMPRESSION");
2153-
unsigned long compression = compression_str ? strtoul(compression_str, nullptr, 10) : 0;
2152+
int compression = jl_options.compress_sysimage ? 15 : 0;
21542153
ArrayRef<char> sysimg_data{z->buf, (size_t)z->size};
21552154
SmallVector<char, 0> compressed_data;
21562155
if (compression) {

src/jloptions.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ JL_DLLEXPORT void jl_init_options(void)
160160
0, // task_metrics
161161
-1, // timeout_for_safepoint_straggler_s
162162
0, // gc_sweep_always_full
163+
0, // compress_sysimage
163164
};
164165
jl_options_initialized = 1;
165166
}
@@ -311,7 +312,10 @@ static const char opts_hidden[] =
311312
" --strip-metadata Remove docstrings and source location info from\n"
312313
" system image\n"
313314
" --strip-ir Remove IR (intermediate representation) of compiled\n"
314-
" functions\n\n"
315+
" functions\n"
316+
" --compress-sysimage={yes|no*} Compress the sys/pkgimage heap at the expense of\n"
317+
" slightly increased load time.\n"
318+
"\n"
315319

316320
// compiler debugging and experimental (see the devdocs for tips on using these options)
317321
" --experimental Enable the use of experimental (alpha) features\n"
@@ -407,6 +411,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
407411
opt_permalloc_pkgimg,
408412
opt_trim,
409413
opt_experimental_features,
414+
opt_compress_sysimage,
410415
};
411416
static const char* const shortopts = "+vhqH:e:E:L:J:C:it:p:O:g:m:";
412417
static const struct option longopts[] = {
@@ -478,6 +483,7 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
478483
{ "heap-target-increment", required_argument, 0, opt_heap_target_increment },
479484
{ "gc-sweep-always-full", no_argument, 0, opt_gc_sweep_always_full },
480485
{ "trim", optional_argument, 0, opt_trim },
486+
{ "compress-sysimage", required_argument, 0, opt_compress_sysimage },
481487
{ 0, 0, 0, 0 }
482488
};
483489

@@ -1060,6 +1066,12 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
10601066
else
10611067
jl_errorf("julia: invalid argument to --task-metrics={yes|no} (%s)", optarg);
10621068
break;
1069+
case opt_compress_sysimage:
1070+
if (!strcmp(optarg,"yes"))
1071+
jl_options.compress_sysimage = 1;
1072+
else if (!strcmp(optarg,"no"))
1073+
jl_options.compress_sysimage = 0;
1074+
break;
10631075
default:
10641076
jl_errorf("julia: unhandled option -- %c\n"
10651077
"This is a bug, please report it.", c);

src/jloptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ typedef struct {
7171
int8_t task_metrics;
7272
int16_t timeout_for_safepoint_straggler_s;
7373
int8_t gc_sweep_always_full;
74+
int8_t compress_sysimage;
7475
} jl_options_t;
7576

7677
#endif

0 commit comments

Comments
 (0)