Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

April perf improvements #621

Merged
merged 18 commits into from
Apr 20, 2022
Merged

April perf improvements #621

merged 18 commits into from
Apr 20, 2022

Conversation

MihaZupan
Copy link
Collaborator

Interesting changes:

  • Reducing the size of AST objects (mainly Inlines)
  • Reducing the cost of type checks by using spare bits on MarkdownObject to store the type and then doing Unsafe casts
  • Avoiding substring allocations to store CodeInline.Content
  • Adding various fast-paths to parsing for the advanced pipeline
  • Faster rendering loop by replacing Type.GetTypeHandle with the method table pointer

Perf:

Default pipeline

Parsing (~5% speedup, ~8% fewer allocated bytes)

Method SourceTexts Mean Error StdDev Median Allocated
Parse MarkdigReadme 279.842 us 0.8528 us 1.2231 us 280.632 us 139,241 B
Parse TracingArticle 37.482 us 0.0957 us 0.1373 us 37.439 us 18,592 B
Parse YarpDocs 2,727.076 us 13.5193 us 19.3889 us 2,740.968 us 1,320,172 B
Method SourceTexts Mean Error StdDev Median Allocated
Parse MarkdigReadme 264.739 us 1.1761 us 1.7240 us 264.500 us 127,737 B
Parse TracingArticle 36.518 us 0.1381 us 0.2024 us 36.614 us 17,088 B
Parse YarpDocs 2,593.829 us 13.2596 us 19.8464 us 2,594.943 us 1,218,524 B

Rendering (2-10% speedup)

Method SourceTexts Mean Error StdDev Median
RenderWithoutToString MarkdigReadme 62.725 us 0.6066 us 0.8891 us 63.415 us
RenderWithoutToString TracingArticle 8.028 us 0.0060 us 0.0088 us 8.028 us
RenderWithoutToString YarpDocs 825.007 us 6.1494 us 9.0137 us 817.198 us
Method SourceTexts Mean Error StdDev Median
RenderWithoutToString MarkdigReadme 61.584 us 1.1683 us 1.5992 us 62.792 us
RenderWithoutToString TracingArticle 7.328 us 0.0051 us 0.0077 us 7.329 us
RenderWithoutToString YarpDocs 786.404 us 4.9851 us 7.3071 us 791.788 us
Advanced pipeline

Parsing (7-16% speedup, ~7% fewer allocated bytes)

Method SourceTexts Mean Error StdDev Median Allocated
Parse MarkdigReadme 414.583 us 2.2855 us 3.4208 us 413.392 us 153,857 B
Parse TracingArticle 69.383 us 0.5513 us 0.7907 us 69.452 us 23,288 B
Parse YarpDocs 6,137.069 us 38.8496 us 51.8631 us 6,175.543 us 2,199,560 B
Method SourceTexts Mean Error StdDev Median Allocated
Parse MarkdigReadme 387.088 us 11.0335 us 16.5144 us 380.891 us 142,273 B
Parse TracingArticle 61.665 us 0.0889 us 0.1217 us 61.675 us 21,784 B
Parse YarpDocs 5,141.475 us 13.8774 us 20.3413 us 5,148.576 us 2,062,000 B

Rendering

Method SourceTexts Mean Error StdDev Median Allocated
RenderWithoutToString MarkdigReadme 72.981 us 0.2856 us 0.3909 us 73.300 us 1,944 B
RenderWithoutToString TracingArticle 8.533 us 0.0166 us 0.0232 us 8.529 us -
RenderWithoutToString YarpDocs 975.213 us 2.5721 us 3.7701 us 977.482 us 2,746 B
Method SourceTexts Mean Error StdDev Median Allocated
RenderWithoutToString MarkdigReadme 69.082 us 0.0590 us 0.0864 us 69.055 us 1,944 B
RenderWithoutToString TracingArticle 7.807 us 0.0147 us 0.0215 us 7.809 us -
RenderWithoutToString YarpDocs 917.742 us 2.4117 us 3.5351 us 918.906 us 2,745 B

@xoofx xoofx merged commit 925d4f9 into xoofx:master Apr 20, 2022
@xoofx
Copy link
Owner

xoofx commented Apr 20, 2022

Great job, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants