From 8e3a117c68a8c8e2086bde4bf72429f3edf79b80 Mon Sep 17 00:00:00 2001 From: NiLuJe Date: Wed, 23 Dec 2020 17:06:08 +0100 Subject: [PATCH] Rejig CBB toggling on startup to avoid an extra jit.flush (#7023) * When the CBB is disabled, attempt to apply the JIT tweaks earlier, avoiding the JIT code flush in the process * Drop debug prints * Bump base https://github.com/koreader/koreader-base/pull/1263 https://github.com/koreader/koreader-base/pull/1264 --- base | 2 +- platform/kobo/nickel.sh | 2 +- reader.lua | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/base b/base index 6b4667756..11de43f6f 160000 --- a/base +++ b/base @@ -1 +1 @@ -Subproject commit 6b46677563f490b570436703c235338ed1d72eea +Subproject commit 11de43f6f98fc13239308e394a6f7b2c082c1c27 diff --git a/platform/kobo/nickel.sh b/platform/kobo/nickel.sh index 44de2a180..7cdf9345f 100755 --- a/platform/kobo/nickel.sh +++ b/platform/kobo/nickel.sh @@ -11,7 +11,7 @@ export LD_LIBRARY_PATH="/usr/local/Kobo" cd / unset OLDPWD unset LC_ALL TESSDATA_PREFIX STARDICT_DATA_DIR EXT_FONT_DIR -unset KOREADER_DIR KO_NO_CBB KO_DONT_GRAB_INPUT +unset KOREADER_DIR KO_DONT_GRAB_INPUT # Ensures fmon will restart. Note that we don't have to worry about reaping this, nickel kills on-animator.sh on start. ( diff --git a/reader.lua b/reader.lua index 89fb1aaac..599cc3ace 100755 --- a/reader.lua +++ b/reader.lua @@ -29,6 +29,15 @@ io.stdout:flush() -- they might call gettext on load G_reader_settings = require("luasettings"):open( DataStorage:getDataDir().."/settings.reader.lua") + +-- Apply the JIT opt tweaks ASAP when the C BB is disabled, +-- because we want to avoid the jit.flush() from bb:enableCBB, +-- which only makes the mcode allocation issues worse on Android... +local is_cbb_enabled = G_reader_settings:nilOrFalse("dev_no_c_blitter") +if not is_cbb_enabled then + jit.opt.start("loopunroll=45") +end + local lang_locale = G_reader_settings:readSetting("language") -- Allow quick switching to Arabic for testing RTL/UI mirroring if os.getenv("KO_RTL") then lang_locale = "ar_AA" end @@ -41,7 +50,8 @@ local dummy = require("ffi/posix_h") -- Try to turn the C blitter on/off, and synchronize setting so that UI config reflects real state local bb = require("ffi/blitbuffer") -local is_cbb_enabled = bb:enableCBB(G_reader_settings:nilOrFalse("dev_no_c_blitter")) +bb:setUseCBB(is_cbb_enabled) +is_cbb_enabled = bb:enableCBB(G_reader_settings:nilOrFalse("dev_no_c_blitter")) G_reader_settings:saveSetting("dev_no_c_blitter", not is_cbb_enabled) -- Should check DEBUG option in arg and turn on DEBUG before loading other