Skip to content

Update default glyph size to be 10,000.#62

Open
j3553a wants to merge 1 commit intopeerless2012:masterfrom
j3553a:master
Open

Update default glyph size to be 10,000.#62
j3553a wants to merge 1 commit intopeerless2012:masterfrom
j3553a:master

Conversation

@j3553a
Copy link
Contributor

@j3553a j3553a commented Feb 25, 2026

This change improves stability and matches the upstream libass repo's default glyph size.

@j3553a j3553a changed the title Update default glyphsize to be 10,000 Update default glyphsize to be 10,000. Feb 25, 2026
@j3553a j3553a changed the title Update default glyphsize to be 10,000. Update default glyph size to be 10,000. Feb 25, 2026
@peerless2012
Copy link
Owner

Is 10000 is too big for mobile devices, some tv memory is very small. Maybe 4096 is enough?

@j3553a
Copy link
Contributor Author

j3553a commented Feb 25, 2026

I would actually anticipate a larger glyph size of 10k will help weaker hardware process the subtitles easier. My understanding is a larger glyph size will help prevent as much "churn" as it tries to purge older glyphs. We still have the 128 MB cache and the 10k limit isn't preallocated. More glyphs might hang around for longer taking a little bit more memory but preventing the constant purging of glyphs should help with performance.

@peerless2012
Copy link
Owner

I worried about more glyph size, the more memory usage, and for a movie, 4096 glyph is enough I think.

@j3553a
Copy link
Contributor Author

j3553a commented Feb 25, 2026

The memory cache is still capped at 128 MB and shouldn't use more than that. The glyph size of 10k will actually just leverage more of that cache. A 1080p glyph would be something like a 60x60 pixel 8 bit alpha bitmap and might use around 4KB of memory per glyph whereas a 4k glyph would be something like 120x120 pixels and might use around 14KB of memory per glyph.

That means at 1024 glyphs it was only using a maximum of 4MB at 1080p and 14MB at 4K. This meant the system only used between 4 and 14 MB of the total 128 MB cache.

A glyph size of 10,000 would give us a range of 40 MB and 140 MB which fits a lot nicer in the 128 MB cache limit and doesn't leave idle preallocated cache memory. A 10k glyph size will allow for stronger hardware to utilize the cache more efficiently and it shouldn't necessarily affect clients with weaker hardware. This change would just utilize the cache it is preallocating in a more affective means.

Not to mention that less glyph churn will help prevent glyphs from being deallocated and cause memory gaps making it harder to fit glyphs into the cache. We should see more contiguous blocks of memory.

@peerless2012
Copy link
Owner

peerless2012 commented Feb 26, 2026

It seems glyph and bitmap share the cache size, and more glyph will keep more memory and make bitmap cache space be small. And on 4k video, the cache is too small.

And you can make a test for 128M and 4096 glyph for a while, let's to see the difference.

@j3553a
Copy link
Contributor Author

j3553a commented Feb 26, 2026

I'll do some testing on 4096 and report back.

@j3553a
Copy link
Contributor Author

j3553a commented Feb 26, 2026

My understanding is that the glyph limit and bitmap cache aren't two separate pools competing for space. The glyphs are the bitmaps. By raising the limit to 10,000, we aren't shrinking the bitmap space. We are just allowing the 128MB cache to actually fill up.

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.

2 participants