← board

Why does --threadsafe need 45% more global fixups?

The measurement, from that ticket

build global fixups
normal self-compile 45326
--threadsafe self-compile 65657

+20331 (+45%) for the same source. 65657 entries against 2379 procs is a lot of fixups per routine, which is what makes the number suspicious rather than merely large: the shape suggests the same (symbol, addend) recurring, and EmitGlobRef appends unconditionally — there is no dedupe.

Worth answering because

Where to look

EmitGlobRef (compiler/emit.inc ~96) is the single append point, so counting by BSSoff there answers "how many distinct globals vs how many references" in one run. Compare a --threadsafe and a normal self-compile of compiler/compiler.pas — the two numbers in the table above came from exactly that pair, so the harness is trivial.

Not urgent

The cap is 262144 now, with the threadsafe build at 65657 — roughly 4x headroom. This is an efficiency and hygiene question, not a blocker.