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(h5p-server): reduce memory and IO when uploading package #2100

Merged
merged 4 commits into from
Mar 5, 2022

Conversation

cabauman
Copy link
Contributor

@cabauman cabauman commented Feb 25, 2022

Reference a single file for identical file paths rather than one file for each. This improvement is limited to content types with copy/paste functionality.

So this came about when I was interacting with a Book Maker activity that has numerous images with 20 copies each (along with audio files for picked up and dropped). When I exported from WordPress and uploaded to Lumi, I noticed a given image/audio count jumps from one to the number of copies. On the other hand, creating a new activity in Lumi with copy/pasted images references a single file. So it's only the upload feature that does this. Next, I tried the reverse to see how WordPress handles uploaded packages, and discovered that one image file remained as one file. So I figured it would be nice to bring that optimization here too.

I tested my changes manually, and it seems to work well. The following screenshot is the result of uploading a package with 8 copy/pasted images before and after the change:

Screenshot 2022-02-25 233528

If you guys welcome this change, I'll look into adding tests to go along with this PR. Off to bed for now!

Thanks for all the hard work on this project.

Reference a single file for identical filepaths rather than one file for each.
@otacke
Copy link
Contributor

otacke commented Feb 25, 2022

Just adding: BookMaker is a non-public content type that's re-purposing CoursePresentation: Removing plenty of things, adding some new, but basically CoursePresentation. Might help for reproducing the initial issue.

@cabauman
Copy link
Contributor Author

cabauman commented Feb 26, 2022

Thanks, Oliver. Can't keep track of them all 😅

@sr258
Copy link
Member

sr258 commented Feb 26, 2022

@cabauman Thank you for the PR! It looks like a very sensible addition and I'd be happy to merge it. If you could add a test that covers the new lines, it is ready to be merged.

@@ -236,12 +236,18 @@ export default class ContentStorer {
)
);

const filepathTonewFilenameMap = new Map<string, string>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably be filepathToNewFilenameMap

Copy link
Contributor Author

@cabauman cabauman Feb 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I'll also go ahead and change the filepath part to filePath for consistency with the rest of the code base.

@cabauman
Copy link
Contributor Author

cabauman commented Feb 27, 2022

Great. Let me know if there's anything you'd like me to tweak in the tests.

@otacke
Copy link
Contributor

otacke commented Feb 27, 2022

@cabauman Thanks that you are donating your time!

@cabauman
Copy link
Contributor Author

@otacke It's a pleasure. I love the open source community.

@sr258 sr258 merged commit 6352040 into Lumieducation:master Mar 5, 2022
@sr258
Copy link
Member

sr258 commented Mar 5, 2022

Thank you for the contribution!

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.

3 participants