From 3ce3b102ddd5b663759ed61bd689b7bbda2ceecd Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Sat, 7 Oct 2023 15:10:53 +0200 Subject: Provide "quick" option for loading database into RAM The directory cache and the database's Load to RAM feature each result in a much better user experience. But, when both features are enabled at the same time, it can take a very long time on older players - easily several minutes for larger libraries - until all of the database's dircache references have been updated. Include a 'Quick' option that causes the database to ignore dircache references which can *significantly* reduce disk activity after booting. Change-Id: I25ae779c97d03885b06d5a28d8be55c0d05692a5 --- apps/lang/english.lang | 14 ++++++++++++++ apps/settings.h | 9 ++++++++- apps/settings_list.c | 5 ++++- apps/tagcache.c | 6 ++++-- manual/rockbox_interface/tagcache.tex | 17 +++++++++++++++-- 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/apps/lang/english.lang b/apps/lang/english.lang index c41033ec81..b326d5fec0 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -16669,3 +16669,17 @@ *: "Remove Queued Tracks?" + + id: LANG_QUICK_IGNORE_DIRACHE + desc: in Settings + user: core + + *: "Quick (Ignore Directory Cache)" + + + *: "Quick (Ignore Directory Cache)" + + + *: "Quick (Ignore Directory Cache)" + + diff --git a/apps/settings.h b/apps/settings.h index 09a01b40a1..ce29e020f7 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -136,6 +136,13 @@ enum }; #endif +enum +{ + TAGCACHE_RAM_OFF = 0, + TAGCACHE_RAM_ON = 1, + TAGCACHE_RAM_QUICK = 2 +}; + /* dir filter options */ /* Note: Any new filter modes need to be added before NUM_FILTER_MODES. * Any new rockbox browse filter modes (accessible through the menu) @@ -576,7 +583,7 @@ struct user_settings #endif #ifdef HAVE_TAGCACHE #ifdef HAVE_TC_RAMCACHE - bool tagcache_ram; /* load tagcache to ram? */ + int tagcache_ram; /* load tagcache to ram: 1=on, 2=quick (ignore dircache) */ #endif bool tagcache_autoupdate; /* automatically keep tagcache in sync? */ bool autoresume_enable; /* enable auto-resume feature? */ diff --git a/apps/settings_list.c b/apps/settings_list.c index bc3708bfba..7bdb3522c0 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -1813,7 +1813,10 @@ const struct settings_list settings[] = { #ifdef HAVE_TAGCACHE #ifdef HAVE_TC_RAMCACHE - OFFON_SETTING(F_BANFROMQS,tagcache_ram,LANG_TAGCACHE_RAM,false,"tagcache_ram",NULL), + CHOICE_SETTING(F_BANFROMQS, tagcache_ram, LANG_TAGCACHE_RAM, + 0, "tagcache_ram", "off,on,quick", + NULL, 3, + ID2P(LANG_OFF), ID2P(LANG_ON), ID2P(LANG_QUICK_IGNORE_DIRACHE)), #endif OFFON_SETTING(F_BANFROMQS, tagcache_autoupdate, LANG_TAGCACHE_AUTOUPDATE, false, "tagcache_autoupdate", NULL), diff --git a/apps/tagcache.c b/apps/tagcache.c index 90f7e01a2f..9463d7c865 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -800,7 +800,8 @@ static long find_entry_ram(const char *filename) struct dircache_fileref dcfref; /* Check if tagcache is loaded into ram. */ - if (!tc_stat.ramcache) + if (!tc_stat.ramcache + || global_settings.tagcache_ram != TAGCACHE_RAM_ON) return -1; if (dircache_search(DCS_CACHED_PATH | DCS_UPDATE_FILEREF, &dcfref, @@ -5247,7 +5248,8 @@ static void tagcache_thread(void) if (!tc_stat.ramcache && global_settings.tagcache_ram) { load_ramcache(); - check_file_refs(global_settings.tagcache_autoupdate); + if (global_settings.tagcache_ram == TAGCACHE_RAM_ON) + check_file_refs(global_settings.tagcache_autoupdate); if (tc_stat.ramcache && global_settings.tagcache_autoupdate) tagcache_build(); } diff --git a/manual/rockbox_interface/tagcache.tex b/manual/rockbox_interface/tagcache.tex index f48aff8e4c..91c0255750 100644 --- a/manual/rockbox_interface/tagcache.tex +++ b/manual/rockbox_interface/tagcache.tex @@ -52,10 +52,23 @@ with logging browsing but it does not use extra RAM and saves some battery on boot up. \opt{HAVE_DISK_STORAGE}{ - \note{If you browse your music frequently using the database, you should + If you browse your music frequently using the database, you should load to RAM, as this will reduce the overall battery consumption because - the disk will not need to spin on each search.} + the disk will not need to spin on each search. } + + \note{When Load to RAM is turned on, and the directory cache is enabled as well, + it may take an unexpectedly long amount of time for disk activity to + wind down after booting, depending on your library size and player. + + This can be mitigated by choosing the \setting{Quick} option instead, which causes + the database to ignore cached file references. In that case, you may notice brief + moments of disk activity once the path for a database entry has to be retrieved. + + Set to \setting{On}, if you plan to take advantage the database's Update function, + or use a WPS that displays multiple upcoming tracks from the current playlist. + Otherwise, you may notice file names instead of metadata being displayed for those + tracks.} } \item[Auto Update] -- cgit v1.2.3