Commit 6763310
authored
Optimize allocations under RuntimeNodeWriter.WriteHtmlContent (#11945)
This method was creating a StringBuilder with unknown size allocating
both a final string and char array along with resize allocations.
Instead, calculate the result length and calculate a single char array.
This reduced allocations in the typing scenario in the razor lsp
speedometer test under this method from about 3.8% to 2.3%.
Speedometer run:
https://dev.azure.com/devdiv/DevDiv/_apps/hub/ms-vseng.pit-vsengPerf.pit-hub?targetBuild=10711.132.dn-bot.250612.042302.643010&targetBranch=main&targetPerfBuildId=11746459&runGroup=Speedometer&baselineBuild=10711.80&baselineBranch=main
Allocations before change

Allocations with change
File tree
2 files changed
+38
-45
lines changed- src/Compiler
- Microsoft.AspNetCore.Razor.Language/test/CodeGeneration
- Microsoft.CodeAnalysis.Razor.Compiler/src/Language/CodeGeneration
2 files changed
+38
-45
lines changedLines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
410 | | - | |
| 410 | + | |
411 | 411 | | |
412 | 412 | | |
413 | 413 | | |
| |||
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | | - | |
| 429 | + | |
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
449 | | - | |
| 449 | + | |
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
| |||
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | | - | |
| 469 | + | |
470 | 470 | | |
471 | 471 | | |
472 | 472 | | |
| |||
Lines changed: 34 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
255 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
256 | 258 | | |
257 | | - | |
| 259 | + | |
258 | 260 | | |
259 | | - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
260 | 265 | | |
261 | 266 | | |
262 | 267 | | |
263 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
264 | 276 | | |
265 | | - | |
| 277 | + | |
266 | 278 | | |
267 | 279 | | |
268 | 280 | | |
269 | | - | |
| 281 | + | |
270 | 282 | | |
271 | | - | |
| 283 | + | |
272 | 284 | | |
273 | | - | |
274 | | - | |
275 | | - | |
| 285 | + | |
| 286 | + | |
276 | 287 | | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
285 | 293 | | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
| 294 | + | |
301 | 295 | | |
302 | | - | |
303 | | - | |
304 | | - | |
| 296 | + | |
| 297 | + | |
305 | 298 | | |
306 | | - | |
307 | | - | |
| 299 | + | |
| 300 | + | |
308 | 301 | | |
309 | | - | |
| 302 | + | |
310 | 303 | | |
311 | 304 | | |
312 | 305 | | |
| |||
0 commit comments