Skip to content

Commit 9dc9d9b

Browse files
kpamnanynickrobinson251
authored andcommitted
Only update the world age when a new method is loaded (#196)
Instead of always updating it. This should speed up loading only method specializations.
1 parent 5385260 commit 9dc9d9b

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/staticdata.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2960,7 +2960,6 @@ static void jl_restore_system_image_from_stream_(ios_t *f, jl_image_t *image, jl
29602960
jl_set_gs_ctr(gs_ctr);
29612961
}
29622962
else {
2963-
jl_atomic_fetch_add(&jl_world_counter, 1);
29642963
offset_restored = jl_read_offset(&s);
29652964
offset_init_order = jl_read_offset(&s);
29662965
offset_extext_methods = jl_read_offset(&s);
@@ -3190,7 +3189,6 @@ static void jl_restore_system_image_from_stream_(ios_t *f, jl_image_t *image, jl
31903189
jl_cache_type_((jl_datatype_t*)obj);
31913190
}
31923191
// Perform fixups: things like updating world ages, inserting methods & specializations, etc.
3193-
size_t world = jl_atomic_load_acquire(&jl_world_counter);
31943192
for (size_t i = 0; i < s.uniquing_objs.len; i++) {
31953193
uintptr_t item = (uintptr_t)s.uniquing_objs.items[i];
31963194
// check whether this is a gvar index
@@ -3244,6 +3242,16 @@ static void jl_restore_system_image_from_stream_(ios_t *f, jl_image_t *image, jl
32443242
o->bits.in_image = 1;
32453243
}
32463244
arraylist_free(&cleanup_list);
3245+
size_t world = jl_atomic_load_relaxed(&jl_world_counter);
3246+
for (size_t i = 0; i < s.fixup_objs.len; i++) {
3247+
// decide if we need to allocate a world
3248+
uintptr_t item = (uintptr_t)s.fixup_objs.items[i];
3249+
jl_value_t *obj = (jl_value_t*)(image_base + item);
3250+
if (jl_is_method(obj)) {
3251+
world = jl_atomic_fetch_add(&jl_world_counter, 1) + 1;
3252+
break;
3253+
}
3254+
}
32473255
for (size_t i = 0; i < s.fixup_objs.len; i++) {
32483256
uintptr_t item = (uintptr_t)s.fixup_objs.items[i];
32493257
jl_value_t *obj = (jl_value_t*)(image_base + item);

src/staticdata_utils.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,10 @@ static jl_array_t *jl_verify_edges(jl_array_t *targets, size_t minworld)
853853
if (ulong_array == NULL)
854854
ulong_array = jl_apply_array_type((jl_value_t*)jl_ulong_type, 1);
855855
jl_array_t *maxvalids = jl_alloc_array_1d(ulong_array, l);
856+
if (minworld == jl_base_module->primary_world) {
857+
memset(jl_array_data(maxvalids), -1, l * sizeof(size_t));
858+
return maxvalids;
859+
}
856860
memset(jl_array_data(maxvalids), 0, l * sizeof(size_t));
857861
jl_value_t *loctag = NULL;
858862
jl_value_t *matches = NULL;

0 commit comments

Comments
 (0)