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

feat: PublishSlides: reduced memory consumption #53

Merged
merged 1 commit into from
May 29, 2022

Conversation

f1nzer
Copy link
Contributor

@f1nzer f1nzer commented May 24, 2022

This PR addresses memory consumption on pptx PublishSlides.

PptxContent copy routine uses media duplicate checking. Images/media were loaded in memory all the time (as a cache, the content was copied to a byte array) and all media were compared against each other on cache lookup (byte by byte comparison). Now, SHA256 hash is computed on media content and stored in memory (256 bits per media data), so cache lookup is based on content type + hash. This optimization removes media byte content from memory and improves cache lookup speed (but needs to compute a cache).

This improvement also affects all operations where CopyMedia/Images are involved (not only PublishSlides).

Rough perf stats on my 1.8 GB pptx file (tested via dotMemory):

Method Allocated objs Allocated bytes PeakMemory Time
PublishSlides_Original 4,911,955 21,079,000,567 4,120,592,384 00:01:16.5428780
PublishSlides_Optimized 4,909,955 13,030,037,546 1,503,330,304 00:01:20.7666303

Peak memory is retrieved via Process.GetCurrentProcess().PeakWorkingSet64

@f1nzer f1nzer closed this May 26, 2022
@sergey-tihon sergey-tihon reopened this May 26, 2022
@sergey-tihon sergey-tihon merged commit f09c320 into sergey-tihon:master May 29, 2022
@sergey-tihon
Copy link
Owner

Thank you @f1nzer !

sergey-tihon added a commit that referenced this pull request May 29, 2022
* master:
  feat: release v1.11
  feat: PublishSlides: reduced memory consumption (#53)

# Conflicts:
#	Clippit/PtOpenXmlUtil.cs
#	RELEASE_NOTES.md
#	paket.lock
@f1nzer f1nzer deleted the feat/pptx-split-memory branch June 2, 2022 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants