Commit ddd51bf
committed
perf: speed up ValidScopedCSSClass in the language server
Two changes that together drop the LSP save latency introduced by
ValidScopedCSSClass from ~4.5s to <500ms on large themes after the
first save of a session.
1. Session-scoped CSS class cache in runChecks
Before, every save tore down the getCSSClassesForURI memoization and
re-parsed every .liquid file with a {% stylesheet %} tag to rebuild
the theme-wide class set. Now the Map<uri, Promise<Set<string>>>
lives at makeRunChecks scope. When a save fires, the saved URI is
evicted from the cache; every other entry stays warm. First save
pays the full scan; subsequent saves re-parse one file.
2. Substring short-circuit in extractCSSClassesFromLiquidUri
Skip toLiquidHtmlAST entirely when source contains no
'{% stylesheet'. On Horizon (240 liquid files, 128 with stylesheet
tags) this skips ~47% of parses on the first scan. Also helps the
CLI: ~19.2s → ~17.4s on Horizon.
Also adds [theme-check] timing logs in runChecks for profiling.1 parent 54e1418 commit ddd51bf
3 files changed
Lines changed: 49 additions & 5 deletions
File tree
- .changeset
- packages
- theme-check-common/src/utils
- theme-language-server-common/src/diagnostics
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
44 | 49 | | |
45 | 50 | | |
46 | 51 | | |
| |||
Lines changed: 38 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
| |||
46 | 52 | | |
47 | 53 | | |
48 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
49 | 63 | | |
50 | 64 | | |
51 | 65 | | |
52 | 66 | | |
| 67 | + | |
53 | 68 | | |
54 | 69 | | |
55 | 70 | | |
56 | 71 | | |
| 72 | + | |
57 | 73 | | |
58 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
59 | 80 | | |
| 81 | + | |
60 | 82 | | |
61 | 83 | | |
62 | 84 | | |
63 | 85 | | |
64 | 86 | | |
| 87 | + | |
65 | 88 | | |
| 89 | + | |
66 | 90 | | |
67 | 91 | | |
68 | 92 | | |
| |||
79 | 103 | | |
80 | 104 | | |
81 | 105 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
87 | 114 | | |
88 | 115 | | |
89 | 116 | | |
| |||
112 | 139 | | |
113 | 140 | | |
114 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
115 | 147 | | |
116 | 148 | | |
117 | 149 | | |
| |||
121 | 153 | | |
122 | 154 | | |
123 | 155 | | |
| 156 | + | |
124 | 157 | | |
125 | 158 | | |
126 | 159 | | |
| |||
0 commit comments