From 0924b57877013e9c11be8a0115b76ca498bc6073 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Sun, 29 Jul 2018 03:53:57 +0200 Subject: [PATCH] Tweak/unbreak my CPUFreq experiment (#4119) * Only switch to ondemand when we actually can, and when it's better than the current governor... This potentially leaves Mk.5 in the lurch, but there's no perfect solution there :/. * Switch to UI for the unmark event of navigation hints markers Might help on non-REAGL devices, and doesn't hurt there (re #3983). * Switch SQLite DBs to WAL Sounds nice in theory, behaves fine in practice. --- .../apps/reader/modules/readerrolling.lua | 2 +- platform/kobo/koreader.sh | 24 +++++++++++++++---- .../coverbrowser.koplugin/bookinfomanager.lua | 2 ++ plugins/statistics.koplugin/main.lua | 2 ++ 4 files changed, 24 insertions(+), 6 deletions(-) diff --git a/frontend/apps/reader/modules/readerrolling.lua b/frontend/apps/reader/modules/readerrolling.lua index 472a34133..36e6b36ef 100644 --- a/frontend/apps/reader/modules/readerrolling.lua +++ b/frontend/apps/reader/modules/readerrolling.lua @@ -497,7 +497,7 @@ function ReaderRolling:onGotoXPointer(xp, marker_xp) -- documents): we drew our black marker in the margin, we -- can just draw a white one to make it disappear Screen.bb:paintRect(0, screen_y, marker_w, marker_h, Blitbuffer.COLOR_WHITE) - Screen["refreshFast"](Screen, 0, screen_y, marker_w, marker_h) + Screen["refreshUI"](Screen, 0, screen_y, marker_w, marker_h) end UIManager:scheduleIn(marker_setting, self.unmark_func) end diff --git a/platform/kobo/koreader.sh b/platform/kobo/koreader.sh index b0aa6a434..784793782 100755 --- a/platform/kobo/koreader.sh +++ b/platform/kobo/koreader.sh @@ -7,9 +7,21 @@ KOREADER_DIR="${0%/*}" # we're always starting from our working directory cd "${KOREADER_DIR}" || exit -# Switch to a sensible CPUFreq governor, even if the HW appears not to give an actual fuck about this... -ORIG_CPUFREQ_GOV="$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)" -echo "ondemand" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" +# Attempt to switch to a sensible CPUFreq governor when that's not already the case... +current_cpufreq_gov="$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)" +# NOTE: We're being fairly conservative here, because what's used and what's available varies depending on HW... +if [ "${current_cpufreq_gov}" != "ondemand" ] && [ "${current_cpufreq_gov}" != "interactive" ]; then + # NOTE: Go with ondemand, because it's likely to be the lowest common denominator. + # Plus, interactive is hard to tune right, and only really interesting when it's a recent version, + # which I somehow doubt is the case anywhere here... + if grep -q ondemand /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors; then + ORIG_CPUFREQ_GOV="${current_cpufreq_gov}" + echo "ondemand" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" + fi +fi +# NOTE: That doesn't actually help us poor userspace plebs, but, short of switching to performance, +# I don't really have a golden bullet here... (conservative's rubberbanding is terrible, so that's a hard pass). +# All I can say is that userspace is a terrible idea and behaves *very* strangely (c.f., #4114). # update to new version from OTA directory ko_update_check() { @@ -136,8 +148,10 @@ while [ $RETURN_VALUE -eq 85 ]; do RETURN_VALUE=$? done -# Restore original CPUFreq governor... -echo "${ORIG_CPUFREQ_GOV}" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" +# Restore original CPUFreq governor if need be... +if [ -n "${ORIG_CPUFREQ_GOV}" ]; then + echo "${ORIG_CPUFREQ_GOV}" >"/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor" +fi if [ "${FROM_NICKEL}" = "true" ]; then if [ "${FROM_KFMON}" != "true" ]; then diff --git a/plugins/coverbrowser.koplugin/bookinfomanager.lua b/plugins/coverbrowser.koplugin/bookinfomanager.lua index 0dde7f091..1507c3e32 100644 --- a/plugins/coverbrowser.koplugin/bookinfomanager.lua +++ b/plugins/coverbrowser.koplugin/bookinfomanager.lua @@ -138,6 +138,8 @@ end function BookInfoManager:createDB() local db_conn = SQ3.open(self.db_location) + -- Make it WAL + db_conn:exec("PRAGMA journal_mode=WAL;") -- Less error cases to check if we do it that way -- Create it (noop if already there) db_conn:exec(BOOKINFO_DB_SCHEMA) diff --git a/plugins/statistics.koplugin/main.lua b/plugins/statistics.koplugin/main.lua index 8d7032a67..2a17e5c44 100755 --- a/plugins/statistics.koplugin/main.lua +++ b/plugins/statistics.koplugin/main.lua @@ -266,6 +266,8 @@ function ReaderStatistics:partialMd5(file) end function ReaderStatistics:createDB(conn) + -- Make it WAL + conn:exec("PRAGMA journal_mode=WAL;") local sql_stmt = [[ CREATE TABLE IF NOT EXISTS book (