-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Performance on Android tablet devices is poor #1416
Comments
It's probably because JIT fails to compile lua code at some circumstances which happens more often in some Android devices and less often in other Android devices. I use Then I came across this sometimes on my Meizu MX4:
When these And I never see these messages on the emulator and on my PocketBook. I have a feeling that it has something to do with this. @hwhw what do you think about this? |
The way you described seems to fit into the behavior I see here. And I have 5x times more KR crashes on Android than any other device i have like Kobos. |
Frankly, it shouldn't crash at all. It's a bit messy to debug. I will need to try to get hold of a device that shows this behaviour, but I can't actually promise anything. |
We could try the workaround described here: |
@thotypous The workaround is like turning off jit and does not suit for Koreader because without jit blitbuffer will be painfully slow even on modern desktop PC. |
Actually, it's not! I think it should definitely be given a try! What it does is to allocate a large chunk of memory in one go, rather than trying to allocate it when need arises. This guarantees a single large chunk of memory. So definitely try inserting 256 seems like a good value. The maximum allocation under default conditions is 512 (kByte) according to this: http://luajit.org/running.html |
Recent reports about crash on Android like in #1447 may indicate that |
By inspecting the memory map of the koreader process on Android:
I'm wondering which address of
|
And this is how does mcode allocation fail. luajit-2.0 $ git diff
diff --git a/src/lj_mcode.c b/src/lj_mcode.c
index 5a73296..dc5dc35 100644
--- a/src/lj_mcode.c
+++ b/src/lj_mcode.c
@@ -212,6 +212,9 @@ static void mcode_protect(jit_State *J, int prot)
#ifdef LJ_TARGET_JUMPRANGE
+#include <stdio.h>
+FILE *mcode_log_file = NULL;
+
/* Get memory within relative jump distance of our code in 64 bit mode. */
static void *mcode_alloc(jit_State *J, size_t sz)
{
@@ -230,10 +233,13 @@ static void *mcode_alloc(jit_State *J, size_t sz)
/* First try a contiguous area below the last one. */
uintptr_t hint = J->mcarea ? (uintptr_t)J->mcarea - sz : 0;
int i;
+ if (mcode_log_file == NULL) mcode_log_file = fopen("/sdcard/mcode_alloc.log", "w+");
+ fprintf(mcode_log_file, "\nprobing mcode alloc(target:%x, range:%x, size:%x)\n", target, range, sz);
for (i = 0; i < 32; i++) { /* 32 attempts ought to be enough ... */
if (mcode_validptr(hint)) {
void *p = mcode_alloc_at(J, hint, sz, MCPROT_GEN);
+ fprintf(mcode_log_file, "%x -> %x ", hint, p);
if (mcode_validptr(p) &&
((uintptr_t)p + sz - target < range || target - (uintptr_t)p < range))
return p;
@@ -245,6 +251,8 @@ static void *mcode_alloc(jit_State *J, size_t sz)
} while (!(hint + sz < range));
hint = target + hint - (range>>1);
}
+ fprintf(mcode_log_file, "\t failed!");
+ fflush(mcode_log_file);
lj_trace_err(J, LJ_TRERR_MCODEAL); /* Give up. OS probably ignores hints? */
return NULL;
} And watched this:
And the maps files of the process is:
And eventually |
And this time I tried to pre-allocate a 512KB memory block at the beginning of
Luckily we succeeded to allocate the memory in one shot and never failed:
The maps file also showed that the block is available at 77c50000:
|
This should fix koreader#1447 and maybe also koreader#1416.
It's found that Koreader for Android is not compatible with Xposed module XPrivacy. See #1456. |
Includes C blitbuffer implementation koreader/koreader-base#571 by @chrox Should help performance degeneration on Android due to mcode allocation failure, see koreader#1416
Includes C blitbuffer implementation koreader/koreader-base#571 by @chrox Should help performance degeneration on Android due to mcode allocation failure, see #1416
Hi
It would be nice if Koreader works like rest of the Android apps on non e-ink devices. The speed of page turning and other operations are painfully slow even on recent fast tablets.
For example when I click on a menu the speed is sometimes even worse than the speed on my e-ink device.
thanks
The text was updated successfully, but these errors were encountered: