Skip to content

Reduce batch size for Anki and Yomitan#916

Merged
ShanaryS merged 2 commits intomainfrom
anki-yomitan-batch
Mar 3, 2026
Merged

Reduce batch size for Anki and Yomitan#916
ShanaryS merged 2 commits intomainfrom
anki-yomitan-batch

Conversation

@ShanaryS
Copy link
Copy Markdown
Collaborator

@ShanaryS ShanaryS commented Mar 2, 2026

fixes #900

  • It seems Anki decks that have complicated css dramatically increases the data being sent which breaks things along the way (or causes crashes). The deck size is not the issue but how much cards we batch at a time. This is only the cardsInfo endpoint which is only used for modified cards (all for first time build). This makes the process slower but is negligible since future syncing will be small and in the background.
  • Added a new build message for the start of a build so users know that it's Anki being queried.
  • Reduced the batching for Yomitan as well as we can trade off a bit of speed there for less RAM.

I'm not sure if these will fixes all the issues for everyone but these changes are necessary at least for some people. We can just design around the lowest common denominator as it comes up.


Did a deeper dive on the API results and the three problematic fields are question, answer, and css. These field accounted for 45kb per card for me out of 45.5kb. So for the users having issues, this is probably a big reason, wasted RAM causing crashes.

@ShanaryS ShanaryS self-assigned this Mar 2, 2026
@ShanaryS ShanaryS added the bug Something isn't working label Mar 2, 2026
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Mar 2, 2026

Deploying asbplayer with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1741a9d
Status: ✅  Deploy successful!
Preview URL: https://1ee77667.asbplayer.pages.dev
Branch Preview URL: https://anki-yomitan-batch.asbplayer.pages.dev

View logs

@killergerbah killergerbah added this to the Extension v1.15.0 milestone Mar 2, 2026
@killergerbah
Copy link
Copy Markdown
Owner

@ShanaryS Feel free to merge whenever you're ready. For what its worth I tried the branch before you pushed the field deletion change and I didn't notice any difference in speed of initial import at all.

@ShanaryS
Copy link
Copy Markdown
Collaborator Author

ShanaryS commented Mar 3, 2026

@killergerbah Yeah I tested it a few days ago on my fast PC at it was a difference of 23s to 27s. I just tested it on a slower PC and it went from 2m to 2m30s so negligible. For 0 modified cards, it takes about 5s to 7s for both. This is all excluding the parsing of the fields, just the getting the notes and cards.

But I think the biggest difference will be in the memory saved as I think most people were simply running out of ram. Without these fields everyone's card should be a bytes to a few kb. We could also prune the fields not configured but we can save that for later if it's needed.

@ShanaryS ShanaryS merged commit 87322b5 into main Mar 3, 2026
2 checks passed
@ShanaryS ShanaryS deleted the anki-yomitan-batch branch March 3, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New annotations struggle with big anki decks

2 participants