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

perf: Optimize pdf generation performance by reducing file I/O #10461

Merged
merged 1 commit into from
Dec 24, 2024

Conversation

filzrev
Copy link
Contributor

@filzrev filzrev commented Dec 14, 2024

This PR intended to optimize PDF generation performance.

On current implementation.

1 . PrintHeaderFooterCore method is called every page numbers. And it access physical every times.
2. When header/footer is specified as string. It process try-catch operation every times.

What's changed in this PR

  1. Add InvalidPathChars checks to detect pdfHeaderTemplate/pdfFooterTemplate is HTML content or not.
  2. Add headerFooterTemplateCache to reduce file I/O.
  3. Rename headerFooterCache to headerFooterPageCache

Copy link

codecov bot commented Dec 14, 2024

Codecov Report

Attention: Patch coverage is 13.63636% with 19 lines in your changes missing coverage. Please review.

Project coverage is 79.35%. Comparing base (fe673ec) to head (80b6806).
Report is 498 commits behind head on main.

Files with missing lines Patch % Lines
src/Docfx.App/PdfBuilder.cs 13.63% 19 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10461      +/-   ##
==========================================
+ Coverage   74.31%   79.35%   +5.03%     
==========================================
  Files         536      547      +11     
  Lines       23189    23639     +450     
  Branches     4056     4062       +6     
==========================================
+ Hits        17234    18759    +1525     
+ Misses       4853     3710    -1143     
- Partials     1102     1170      +68     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yufeih yufeih added the performance Makes the pull request appear in "Performance" section of the next release note label Dec 24, 2024
@yufeih yufeih merged commit 16e2a3f into dotnet:main Dec 24, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Makes the pull request appear in "Performance" section of the next release note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants