Skip to content

Commit fb5fffd

Browse files
committed
staticdata: stop compressing and storing large IR
Compressing IR adds Methods roots, which tend to become quite expensive to store after some time. We also used to store the inferred code, but since we never actually look at that again now (since now the compiler avoids using --output-ji or --sysimage-native-code=no or --pkgimages=no) it is now quite a bit of wasted space also. For some reason, this also generates 20% more native code in the system image, which isn't quite clear if that is good or not.
1 parent 7193a6a commit fb5fffd

File tree

4 files changed

+13
-46
lines changed

4 files changed

+13
-46
lines changed

src/aotcompile.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -675,20 +675,6 @@ void *jl_create_native_impl(jl_array_t *methods, LLVMOrcThreadSafeModuleRef llvm
675675
fargs[0] = (jl_value_t*)codeinfos;
676676
void *data = jl_emit_native(codeinfos, llvmmod, &cgparams, external_linkage);
677677

678-
// examine everything just emitted and save it to the caches
679-
if (!external_linkage) {
680-
for (size_t i = 0, l = jl_array_nrows(codeinfos); i < l; i++) {
681-
jl_value_t *item = jl_array_ptr_ref(codeinfos, i);
682-
if (jl_is_code_instance(item)) {
683-
// now add it to our compilation results
684-
jl_code_instance_t *codeinst = (jl_code_instance_t*)item;
685-
jl_code_info_t *src = (jl_code_info_t*)jl_array_ptr_ref(codeinfos, ++i);
686-
assert(jl_is_code_info(src));
687-
jl_add_codeinst_to_cache(codeinst, src);
688-
}
689-
}
690-
}
691-
692678
// move everything inside, now that we've merged everything
693679
// (before adding the exported headers)
694680
((jl_native_code_desc_t*)data)->M.withModuleDo([&](Module &M) {

src/gf.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2836,30 +2836,10 @@ void jl_read_codeinst_invoke(jl_code_instance_t *ci, uint8_t *specsigflags, jl_c
28362836

28372837
jl_method_instance_t *jl_normalize_to_compilable_mi(jl_method_instance_t *mi JL_PROPAGATES_ROOT);
28382838

2839-
JL_DLLEXPORT void jl_add_codeinst_to_cache(jl_code_instance_t *codeinst, jl_code_info_t *src)
2840-
{
2841-
assert(jl_is_code_info(src));
2842-
jl_method_instance_t *mi = jl_get_ci_mi(codeinst);
2843-
if (jl_generating_output() && jl_is_method(mi->def.method) && jl_atomic_load_relaxed(&codeinst->inferred) == jl_nothing) {
2844-
jl_value_t *compressed = jl_compress_ir(mi->def.method, src);
2845-
// These should already be compatible (and should be an assert), but make sure of it anyways
2846-
if (jl_is_svec(src->edges)) {
2847-
jl_atomic_store_release(&codeinst->edges, (jl_svec_t*)src->edges);
2848-
jl_gc_wb(codeinst, src->edges);
2849-
}
2850-
jl_atomic_store_release(&codeinst->debuginfo, src->debuginfo);
2851-
jl_gc_wb(codeinst, src->debuginfo);
2852-
jl_atomic_store_release(&codeinst->inferred, compressed);
2853-
jl_gc_wb(codeinst, compressed);
2854-
}
2855-
}
2856-
2857-
28582839
JL_DLLEXPORT void jl_add_codeinst_to_jit(jl_code_instance_t *codeinst, jl_code_info_t *src)
28592840
{
28602841
assert(jl_is_code_info(src));
28612842
jl_emit_codeinst_to_jit(codeinst, src);
2862-
jl_add_codeinst_to_cache(codeinst, src);
28632843
}
28642844

28652845
jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t world)

src/julia_internal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,6 @@ JL_DLLEXPORT jl_method_instance_t *jl_get_unspecialized(jl_method_t *def JL_PROP
685685
JL_DLLEXPORT void jl_read_codeinst_invoke(jl_code_instance_t *ci, uint8_t *specsigflags, jl_callptr_t *invoke, void **specptr, int waitcompile);
686686
JL_DLLEXPORT jl_method_instance_t *jl_method_match_to_mi(jl_method_match_t *match, size_t world, size_t min_valid, size_t max_valid, int mt_cache);
687687
JL_DLLEXPORT void jl_add_codeinst_to_jit(jl_code_instance_t *codeinst, jl_code_info_t *src);
688-
JL_DLLEXPORT void jl_add_codeinst_to_cache(jl_code_instance_t *codeinst, jl_code_info_t *src);
689688

690689
JL_DLLEXPORT jl_code_instance_t *jl_new_codeinst_uninit(jl_method_instance_t *mi, jl_value_t *owner);
691690
JL_DLLEXPORT jl_code_instance_t *jl_new_codeinst(

src/staticdata.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -934,18 +934,20 @@ static void jl_insert_into_serialization_queue(jl_serializer_state *s, jl_value_
934934
assert(!jl_object_in_image((jl_value_t*)tn->wrapper));
935935
}
936936
}
937-
if (s->incremental && jl_is_code_instance(v)) {
937+
if (jl_is_code_instance(v)) {
938938
jl_code_instance_t *ci = (jl_code_instance_t*)v;
939939
jl_method_instance_t *mi = jl_get_ci_mi(ci);
940-
// make sure we don't serialize other reachable cache entries of foreign methods
941-
// Should this now be:
942-
// if (ci !in ci->defs->cache)
943-
// record_field_change((jl_value_t**)&ci->next, NULL);
944-
// Why are we checking that the method/module this originates from is in_image?
945-
// and then disconnect this CI?
946-
if (jl_object_in_image((jl_value_t*)mi->def.value)) {
947-
// TODO: if (ci in ci->defs->cache)
948-
record_field_change((jl_value_t**)&ci->next, NULL);
940+
if (s->incremental) {
941+
// make sure we don't serialize other reachable cache entries of foreign methods
942+
// Should this now be:
943+
// if (ci !in ci->defs->cache)
944+
// record_field_change((jl_value_t**)&ci->next, NULL);
945+
// Why are we checking that the method/module this originates from is in_image?
946+
// and then disconnect this CI?
947+
if (jl_object_in_image((jl_value_t*)mi->def.value)) {
948+
// TODO: if (ci in ci->defs->cache)
949+
record_field_change((jl_value_t**)&ci->next, NULL);
950+
}
949951
}
950952
jl_value_t *inferred = jl_atomic_load_relaxed(&ci->inferred);
951953
if (inferred && inferred != jl_nothing) { // disregard if there is nothing here to delete (e.g. builtins, unspecialized)
@@ -973,7 +975,7 @@ static void jl_insert_into_serialization_queue(jl_serializer_state *s, jl_value_
973975
if (inferred == jl_nothing) {
974976
record_field_change((jl_value_t**)&ci->inferred, jl_nothing);
975977
}
976-
else if (jl_is_string(inferred)) {
978+
else if (s->incremental && jl_is_string(inferred)) {
977979
// New roots for external methods
978980
if (jl_object_in_image((jl_value_t*)def)) {
979981
void **pfound = ptrhash_bp(&s->method_roots_index, def);

0 commit comments

Comments
 (0)