Skip to content
New issue

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

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

Already on GitHub? # to your account

perf: cache the bundles after we fetched them once #260

Merged
merged 3 commits into from
Feb 5, 2025

Conversation

joanise
Copy link
Member

@joanise joanise commented Feb 3, 2025

PR Goal?

For a process using convert_prealigned_text_to_offline_html() in the Studio API to create a number of different readalongs, fetching the bundles is pretty slow, and has to be done repeatedly for each readalong created. Running the EveryVoice demo on our cluster, that represented an additional 3 second delay each time I clicked the synthesize button, on top of the actual synthesis time.

The solution I adopted here is simply to save the bundle contents in a file-global variable in make_package.py, so we only ever try to fetch each of the two bundle files once.

Memory cost: the bundles take 600KB together, so after the first fetch I'm reserving .6MB for this cache, which is pretty trivial.

Feedback sought?

sanity checking

Priority?

low

Tests added?

code already covered

Yes

How to test?

Run the everyvoice demo with this branch of Studio vs main, and see synthesis run faster the second and subsequent time.

Confidence?

high

Version change?

Patch, but only when we decide we really want this included in the EV demo...

Copy link

semanticdiff-com bot commented Feb 3, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  readalongs/text/make_package.py  63% smaller
  test/test_api.py  0% smaller

@joanise joanise requested a review from roedoejet February 3, 2025 21:54
@joanise joanise changed the title perf: cache the bundles once we fetched them once perf: cache the bundles after we fetched them once Feb 3, 2025
Copy link

codecov bot commented Feb 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.22%. Comparing base (301a46a) to head (f592a34).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #260      +/-   ##
==========================================
+ Coverage   88.08%   88.22%   +0.14%     
==========================================
  Files          22       22              
  Lines        1830     1835       +5     
  Branches      330      332       +2     
==========================================
+ Hits         1612     1619       +7     
+ Misses        180      179       -1     
+ Partials       38       37       -1     

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

Copy link
Collaborator

@roedoejet roedoejet left a comment

Choose a reason for hiding this comment

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

Nice optimization @joanise - lgtm

@joanise joanise merged commit a505105 into main Feb 5, 2025
8 checks passed
@joanise joanise deleted the dev.ej/optimize-api-bundles branch February 5, 2025 20:25
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants