Skip to content

Commit 9162ec8

Browse files
authored
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 8fe069c commit 9162ec8

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
@@ -2952,7 +2952,6 @@ static void jl_restore_system_image_from_stream_(ios_t *f, jl_image_t *image, jl
29522952
jl_set_gs_ctr(gs_ctr);
29532953
}
29542954
else {
2955-
jl_atomic_fetch_add(&jl_world_counter, 1);
29562955
offset_restored = jl_read_offset(&s);
29572956
offset_init_order = jl_read_offset(&s);
29582957
offset_extext_methods = jl_read_offset(&s);
@@ -3182,7 +3181,6 @@ static void jl_restore_system_image_from_stream_(ios_t *f, jl_image_t *image, jl
31823181
jl_cache_type_((jl_datatype_t*)obj);
31833182
}
31843183
// Perform fixups: things like updating world ages, inserting methods & specializations, etc.
3185-
size_t world = jl_atomic_load_acquire(&jl_world_counter);
31863184
for (size_t i = 0; i < s.uniquing_objs.len; i++) {
31873185
uintptr_t item = (uintptr_t)s.uniquing_objs.items[i];
31883186
// check whether this is a gvar index
@@ -3236,6 +3234,16 @@ static void jl_restore_system_image_from_stream_(ios_t *f, jl_image_t *image, jl
32363234
o->bits.in_image = 1;
32373235
}
32383236
arraylist_free(&cleanup_list);
3237+
size_t world = jl_atomic_load_relaxed(&jl_world_counter);
3238+
for (size_t i = 0; i < s.fixup_objs.len; i++) {
3239+
// decide if we need to allocate a world
3240+
uintptr_t item = (uintptr_t)s.fixup_objs.items[i];
3241+
jl_value_t *obj = (jl_value_t*)(image_base + item);
3242+
if (jl_is_method(obj)) {
3243+
world = jl_atomic_fetch_add(&jl_world_counter, 1) + 1;
3244+
break;
3245+
}
3246+
}
32393247
for (size_t i = 0; i < s.fixup_objs.len; i++) {
32403248
uintptr_t item = (uintptr_t)s.fixup_objs.items[i];
32413249
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
@@ -840,6 +840,10 @@ static jl_array_t *jl_verify_edges(jl_array_t *targets, size_t minworld)
840840
if (ulong_array == NULL)
841841
ulong_array = jl_apply_array_type((jl_value_t*)jl_ulong_type, 1);
842842
jl_array_t *maxvalids = jl_alloc_array_1d(ulong_array, l);
843+
if (minworld == jl_base_module->primary_world) {
844+
memset(jl_array_data(maxvalids), -1, l * sizeof(size_t));
845+
return maxvalids;
846+
}
843847
memset(jl_array_data(maxvalids), 0, l * sizeof(size_t));
844848
jl_value_t *loctag = NULL;
845849
jl_value_t *matches = NULL;

0 commit comments

Comments
 (0)