Skip to content

Commit 619ca3d

Browse files
committed
devdocs: Add "localized world age" documentation
1 parent fda38cc commit 619ca3d

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

doc/src/devdocs/world_age.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# World Age Semantics in Julia
2+
3+
## Global World Age
4+
5+
The global world age is a monotonically increasing counter that increments whenever a dispatch-impacting event occurs, such as:
6+
- `Method` registration (`Method` addition or deletion)
7+
- `Binding` modification (re-defining a function or constant)
8+
9+
A `world` represents a snapshot of the dispatch state at a given point in time.
10+
11+
## Localized World Ages
12+
13+
A "localized world age" is similar, but it only tracks changes to specific portions of the method table.
14+
15+
Each `Core.MethodTable` has a `local_age` field that counts dispatch-affecting events specific to that function. For example, a method registration for `read(::Foo)` affects the global world age, as well as the local age of `read`, but it would not be counted as part of the local age of `write`.
16+
17+
Similar to the global world age, Julia can use these ages to refer to a "snapshot" of portions of the method table and avoid unnecessary validation when loading packages. During precompilation, Julia records the local age of each MethodTable it queries. If the latest local age matches the pre-compiled "snapshot", the compiler can skip revalidation for that function, improving load times.
18+
19+
Loading guarantees that all of the dispatch-affecting events that happened during pre-compilation are applied to the dispatch table again at run-time, so that any modifications from other loaded packages (outside of our pre-compilation dependencies) would trigger a strictly larger local age.

0 commit comments

Comments
 (0)