You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf: Reuse one shared context parser + document loader across all files
Components.js constructs a fresh PrefetchedDocumentLoader and (indirectly,
via jsonld-streaming-parser) a fresh ContextParser for every .jsonld file.
As a result the well-known @contexts are re-loaded and re-normalized once
per file: profiling a Community Solid Server boot showed >50% of active CPU
inside jsonld-context-parser, with the componentsjs ^5.0.0 context alone
normalized ~979 times.
This threads a single, optionally cache-bearing ContextParser (carrying one
shared PrefetchedDocumentLoader and raw-document cache) through the whole
component/config load:
- RdfParser.createSharedContextParser(...) builds the shared parser, attaching
a normalized-context cache when the installed jsonld-context-parser exposes
one (feature-detected, so older versions keep working).
- RdfParserOptions gains an optional `contextParser`, forwarded to the JSON-LD
parser as the `contextParser` option (honoured by a jsonld-streaming-parser
that supports injecting a context parser; ignored otherwise). A per-file
document loader is still provided as a fallback, preserving prior behaviour.
- ComponentsManagerBuilder creates the shared parser once and hands it to both
the ComponentRegistry and ConfigRegistry (and, transitively, to imported
files via RdfStreamIncluder).
The change is backwards compatible and fully covered; the existing suite stays
green (865 tests, 100% coverage).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
0 commit comments