Commit 8ec9a73
perf: Pre-expand the Override type and avoid Object.entries in the override scan
ConfigPreprocessorOverride.findOverrideTargets() scans every resource in
the shared RdfObjectLoader (15,814 resources during a Community Solid
Server default-config boot) to find oo:Override resources. Two avoidable
costs per boot:
1. `resource.isA(IRIS_OO.Override)` is called with a *string*, so
Resource#isA re-runs term expansion for every resource in the loader.
IRIS_OO.Override is a constant absolute IRI, so it can be converted
to a term once, outside the loop.
2. `Object.entries(...)` materializes a [ key, value ] pair array per
resource purely for iteration; `Object.keys(...)` + index lookup
avoids that allocation.
Behaviour is unchanged: `isA(term)` is exactly what `isA(string)` does
after expanding the string, and iteration order and results are
identical.
Isolated A/B on the real CSS boot object graph (15,814 resources, warm,
median of 40 reps, 2-core shared box, this branch's build):
original (Object.entries + isA(string)) : 23.6 ms (min 20.4)
pre-expanded term + Object.keys : 12.4 ms (min 11.6) ~1.9x
The optimized scan returns the identical (empty) override set for the
default config, and the full test suite (including all override tests)
is unchanged and green. Small in absolute terms, but it is the single
biggest componentsjs-owned CPU frame in the instantiate phase and is
pure waste for the common zero-override configuration.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 0512b9a commit 8ec9a73
1 file changed
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
113 | | - | |
114 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
115 | 121 | | |
116 | 122 | | |
117 | 123 | | |
| |||
0 commit comments