Commit 3f8674d
authored
perf: cache compiled JSON schemas to improve compilation speed (#2433)
* perf: cache compiled JSON schemas to improve compilation speed
Optimize workflow compilation by caching compiled JSON schemas instead
of recompiling them for every workflow validation. This eliminates
redundant schema parsing and compilation overhead.
Changes:
- pkg/parser/schema.go: Cache frontmatter schema compilation
- Add sync.Once pattern for main workflow, included file, and MCP config schemas
- Schemas are now compiled once and reused across all workflow compilations
- pkg/workflow/validation.go: Cache GitHub Actions schema compilation
- Add sync.Once pattern for GitHub Actions workflow schema
- Schema compilation now happens once per process lifetime
Performance Impact:
- Eliminates repeated JSON schema parsing and compilation overhead
- More significant on slower systems or when compiling many workflows
- Zero performance regression, maintains full schema validation
Trade-offs:
- Complexity: +100 lines of caching logic (well-structured, thread-safe)
- Memory: Minimal (cached schemas ~100KB total)
- Maintainability: No impact (localized changes, clear pattern)
Validation:
- All unit tests pass
- All integration tests pass
- Code formatted with gofmt
- No linting errors
- Tested with compilation of 56 workflows successfully
* chore: add changeset for schema compilation caching [skip-ci]
---------
Co-authored-by: Daily Perf Improver <github-actions[bot]@users.noreply.github.com>1 parent cd55d81 commit 3f8674d
File tree
3 files changed
+117
-21
lines changed- .changeset
- pkg
- parser
- workflow
3 files changed
+117
-21
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
123 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
124 | 165 | | |
125 | 166 | | |
126 | 167 | | |
127 | 168 | | |
128 | 169 | | |
129 | 170 | | |
130 | | - | |
| 171 | + | |
131 | 172 | | |
132 | 173 | | |
133 | | - | |
134 | | - | |
| 174 | + | |
135 | 175 | | |
136 | | - | |
| 176 | + | |
137 | 177 | | |
138 | 178 | | |
139 | 179 | | |
140 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
141 | 206 | | |
142 | 207 | | |
143 | 208 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
221 | 260 | | |
222 | 261 | | |
223 | 262 | | |
| |||
231 | 270 | | |
232 | 271 | | |
233 | 272 | | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
| 273 | + | |
| 274 | + | |
249 | 275 | | |
250 | | - | |
| 276 | + | |
251 | 277 | | |
252 | 278 | | |
253 | 279 | | |
| |||
0 commit comments