Commit c49d97f
committed
perf: add caching layer for frequently accessed operations
Add instance and result caching for hot paths in the rendering pipeline:
- ProjectNode: cache root document entry with O(1) lookup, add fast-path
to getDocumentEntry(), lazy cache invalidation in setDocumentEntries()
- DocumentNode: add hasDocumentEntry() helper for safe checks
- RenderContext: use hash map for O(1) document lookup by file path,
optimize withDocument() to clone directly instead of rebuilding
- DocumentNameResolver: cache URI analysis and resolved paths
- ExternalReferenceResolver: pre-compile schema regex pattern
- SluggerAnchorNormalizer: cache slugger instance and normalization results
- AbstractUrlGenerator: cache isRelativePath() checks
- RelativeUrlGenerator: cache computed relative paths
- PreNodeRendererFactory: cache renderer lookups by node class
- TwigEnvironmentBuilder: enable filesystem template caching
- TwigTemplateRenderer: cache global context to avoid redundant addGlobal()
See https://cybottm.github.io/render-guides/ for benchmark data.1 parent 5820131 commit c49d97f
File tree
10 files changed
+562
-33
lines changed- packages/guides/src
- NodeRenderers/PreRenderers
- Nodes
- ReferenceResolvers
- Renderer/UrlGenerator
- Twig
10 files changed
+562
-33
lines changedLines changed: 15 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
27 | 34 | | |
28 | 35 | | |
29 | 36 | | |
| |||
33 | 40 | | |
34 | 41 | | |
35 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
36 | 49 | | |
37 | 50 | | |
38 | 51 | | |
| |||
43 | 56 | | |
44 | 57 | | |
45 | 58 | | |
46 | | - | |
| 59 | + | |
47 | 60 | | |
48 | 61 | | |
49 | | - | |
| 62 | + | |
50 | 63 | | |
51 | 64 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
279 | 279 | | |
280 | 280 | | |
281 | 281 | | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
282 | 287 | | |
283 | 288 | | |
284 | 289 | | |
| |||
Lines changed: 37 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
26 | 38 | | |
27 | 39 | | |
28 | 40 | | |
| |||
31 | 43 | | |
32 | 44 | | |
33 | 45 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
37 | 60 | | |
38 | 61 | | |
39 | | - | |
40 | | - | |
| 62 | + | |
| 63 | + | |
41 | 64 | | |
42 | 65 | | |
43 | 66 | | |
44 | | - | |
| 67 | + | |
45 | 68 | | |
46 | 69 | | |
47 | | - | |
| 70 | + | |
48 | 71 | | |
49 | 72 | | |
50 | 73 | | |
| |||
57 | 80 | | |
58 | 81 | | |
59 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
60 | 88 | | |
61 | | - | |
| 89 | + | |
62 | 90 | | |
63 | 91 | | |
64 | 92 | | |
| |||
78 | 106 | | |
79 | 107 | | |
80 | 108 | | |
81 | | - | |
| 109 | + | |
82 | 110 | | |
83 | 111 | | |
0 commit comments