This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#12299 - Font Glyph cache is no longer getting saved
Attached to Project:
Rockbox
Opened by Fred Bauer (freddyb) - Thursday, 29 September 2011, 04:47 GMT+2
Last edited by Fred Bauer (freddyb) - Monday, 17 October 2011, 03:51 GMT+2
Opened by Fred Bauer (freddyb) - Thursday, 29 September 2011, 04:47 GMT+2
Last edited by Fred Bauer (freddyb) - Monday, 17 October 2011, 03:51 GMT+2
|
Detailsedit: the later patches save a glyph file for each font instead of the original solution immediately below. i.e. /.rockbox/fonts/15-Times.fnt would have a glyphcache file /.rockbox/fonts/15-Times.glyphcache. -FB
The font system is no longer saving the .glyphcache file. This file data is used to preload the most recently used glyphs in disk order when loading a cached font to reduce the number of disk seeks. I'm posting this fix for review because it changes the old behavior a bit. Doing this right should improve font loading, especially for non-English users. 1) Saves the LRU data of the cached font with the most glyphs in memory. It did use FONT_UI for a long time but that might not be the best choice anymore as ID3 tags might be displayed by a skin font. 2) Only overwrites the existing file if it has more LRU data. 3) Doesn't write the file for less than 20 entries. 4) Removes a kludge in the glyph cache reading code for an old bug that no longer exists. |
This task depends upon
Closed by Fred Bauer (freddyb)
Monday, 17 October 2011, 03:51 GMT+2
Reason for closing: Fixed
Additional comments about closing: in r30760. Each font now gets its own glyphcache file.
Monday, 17 October 2011, 03:51 GMT+2
Reason for closing: Fixed
Additional comments about closing: in r30760. Each font now gets its own glyphcache file.
1) might be ok, but why save only if it has "more LRU data"? The point isn't to save the biggest, but the mos recent data.
Two possible solutions:
1) use a compltly seperate LRU for glyhcache which just stores the glyph code and no data for the most recent X glyphs (lru is cheap so probbaly 1000) and load as many as the font can handle
2) store a seperate .glyphcache file for each font. This should be mostly trivial to do now, just get the font filename from the handle (core_get_name()) and rejig that to a file in /.rockbox/<filename>.glyphcache
I prefer 2 as it is more likely to cause cache hits, and the extra code to handle it shouldnt be much more than the above patch anyway.
And I guess you didnt see the mailing list then? I might work on this but no promises, I'm not actively contributing anymore so a proper solution should be done by "someone" (-else). and yes, my option 2 is a very least-bad option.
Attached is my implementation of 2. I've given it a quick test but without non-latin files its hard to do it properly. This saves/loads /.rockbox/<font name>.glyphcache so ti should corrreclty reflect individual font usages. I'm not completly sure that is the best place for them, possibly actually alongside the font, or differently named...
anyway, have a play and commit it if it works.
Edit: The data abort happens in glyph_cache_save().
I am sure that I have deleted the glyphcache-files before my test. Nevertheless I will test your updated patch.
edit: data abort on shutdown though...
In glyph_cache_save(), the struct font* is used after yielding I/O (open()). It should be re-aquired afterwards. Same thing in glyph_cache_load() if I see this right.
re font_shrinkfilename... pretty sure you're tihnking about something in apps.
Edit: Sorry, I should have applied the patch before testing...
Here are the results after applying the patch.
1. Font-reloading olny happens with the first track skip after buffering has been finished. I can live with that.
2. With each shutdown of the device a new (empty) glyphcache file is created. See my posted image from above.
Result:
1) Even the first skip does not result in a disk spinup (maybe this is/was caused by the disk write access?). There is no font reloading or diskspin up occuring except when buffering is required.
2) Of course there is no glyphcache file created at all (as expected).
Removed all locking code.
Fixed and inlined glyphcache file pathname generation.
Andree: glyph_cache_load() will preload the glyph codes 32 to 255 (up to capacity) if opening the glyph cache file fails, so you shouldn't see a disk spin up for fonts unless you're using glyphs beyond that range.
Edit: Patched against r30740.
Did not shorten the buflib font handle name since that is a separate issue and might cause problems if a font is loaded from outside of the the font directory.
Changed powermgmt.c to call glyph_cache_save_all().
The UI simulator has no equivalent of shutdown_hw() where glyph_cache_save_all() would be called so the simulator will not save glyphcache files unless you change themes or fonts.
Andree: If you test this, would you do a "make clean; make reconf" first?
But: Each on/off-cycle still adds a new glyphcache-file of the same name than the existing ones. I have attached two of the those files (the second is the type of file that is created with each on/off-cycle).
Another issue is that the first buffering of audio data (pressing play for the very first time after startup) will show HDD actitivity 2 times. First long HDD access is ~10-14s -- this should be the audio data buffering. The the disk spins down and up again for a short time -- font loading? This happens for each first buffering after restart.
I have also attached my current WPS incl. the fonts and the config.cfg.
Edit: Just in case this helps -> I am using embedded coverart in each track.
What solves the problem is when I add a small check to glyph_cache_save(). The code checks if the cache-file already exists (just via trying to open it), and does not re-create it in this case.
So, the question is why does "open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0666);" create a new file of the same name if there is already one existing? I cannot even copy those mutliple files to my local HDD because they overwrite themselves...