The default time to run a .dex Java/.class file when invoking the dallvikvm script takes close to 4 seconds
I made a run on my own version of javap and here are the results
[/data/data/com.termux/files/home] 127
-> time dalvikvm props.javap htel.Ssi
Compiled from: htel.Ssi
public class htel.Ssi extends java.lang.Object {
java.io.BufferedInputStream bi;
java.io.BufferedOutputStream bo;
java.io.BufferedReader br;
java.io.InputStream i;
java.lang.String inputname;
java.lang.String name;
htel.Ssi next;
public java.io.OutputStream o;
java.io.PrintWriter pw;
boolean t;
static java.lang.String lock;
public htel.Ssi(java.io.InputStream);
public htel.Ssi(java.io.OutputStream);
public static void msg(java.lang.String);
private int read(byte[], int, boolean) throws java.io.IOException;
public void add(htel.Ssi);
public void close() throws java.io.IOException;
public void dump(byte[], int, int);
public void flush();
public java.lang.String name();
public void name(java.lang.String);
public void println(java.lang.String);
public int read(byte[]) throws java.io.IOException;
public int read(byte[], int) throws java.io.IOException;
public java.lang.String readLine() throws java.io.IOException;
public void readN(byte[]) throws java.io.IOException;
public void trace(boolean);
public boolean trace();
public void write(byte[]) throws java.io.IOException;
public void write(byte[], int, int) throws java.io.IOException;
}
real 0m3.807s
user 0m8.591s
sys 0m0.598s
So I modified dalvikvm script to add
-Xnoimage-dex2oat
And the performance is back to
real 0m0.603s
user 0m0.457s
sys 0m0.140s
The default on the binary /system/bin/dallvikvm on Android 11 has changed to generate an OAT file on every invocation which is not needed when simply running a .dex/.class file.
I compared older versions of /system/bin/dallvikvm and found out that the -Xnoimage-dex2oat was in fact the default.
However on some Android 11 it is not
Steps to reproduce the behavior.
Write any Hello hello world in Java
Use ecj to get .class file
Use dx to make a .dex file
Add dex file to CLASSPATH
use dalvikvm mypackage.Hello
Problem description
The default time to run a .dex Java/.class file when invoking the dallvikvm script takes close to 4 seconds
I made a run on my own version of javap and here are the results [/data/data/com.termux/files/home] 127 -> time dalvikvm props.javap htel.Ssi Compiled from: htel.Ssi public class htel.Ssi extends java.lang.Object { java.io.BufferedInputStream bi; java.io.BufferedOutputStream bo; java.io.BufferedReader br; java.io.InputStream i; java.lang.String inputname; java.lang.String name; htel.Ssi next; public java.io.OutputStream o; java.io.PrintWriter pw; boolean t; static java.lang.String lock; public htel.Ssi(java.io.InputStream); public htel.Ssi(java.io.OutputStream); public static void msg(java.lang.String); private int read(byte[], int, boolean) throws java.io.IOException; public void add(htel.Ssi); public void close() throws java.io.IOException; public void dump(byte[], int, int); public void flush(); public java.lang.String name(); public void name(java.lang.String); public void println(java.lang.String); public int read(byte[]) throws java.io.IOException; public int read(byte[], int) throws java.io.IOException; public java.lang.String readLine() throws java.io.IOException; public void readN(byte[]) throws java.io.IOException; public void trace(boolean); public boolean trace(); public void write(byte[]) throws java.io.IOException; public void write(byte[], int, int) throws java.io.IOException; }
real 0m3.807s user 0m8.591s sys 0m0.598s
So I modified dalvikvm script to add -Xnoimage-dex2oat And the performance is back to real 0m0.603s user 0m0.457s sys 0m0.140s
The default on the binary /system/bin/dallvikvm on Android 11 has changed to generate an OAT file on every invocation which is not needed when simply running a .dex/.class file.
I compared older versions of /system/bin/dallvikvm and found out that the -Xnoimage-dex2oat was in fact the default. However on some Android 11 it is not
Steps to reproduce the behavior.
Write any Hello hello world in Java Use ecj to get .class file Use dx to make a .dex file Add dex file to CLASSPATH use dalvikvm mypackage.Hello
What is the expected behavior?
Subsecond response time instead of 3.8 seconds
System information
Termux application version: Termux Variables: unsupported Packages CPU architecture: aarch64 Subscribed repositories:
sources.list
deb https://packages.termux.dev/apt/termux-main/ stable main
x11-repo (sources.list.d/x11.list)
deb https://packages.termux.dev/apt/termux-x11 x11 main Updatable packages: Listing... curl/stable 7.85.0 aarch64 [upgradable from: 7.84.0] inetutils/stable 2.3-1 aarch64 [upgradable from: 2.3] libcurl/stable 7.85.0 aarch64 [upgradable from: 7.84.0] libevent/stable 2.1.12-2 aarch64 [upgradable from: 2.1.12-1] libexpat/stable 2.4.8-1 aarch64 [upgradable from: 2.4.8] openssl/stable 3.0.5 aarch64 [upgradable from: 3.0.3-1] termux-tools version: 1.29.1 Android version: 12 Kernel build information: Linux localhost 5.10.66-android12-9-24537318-abA536USQU2AVG2 termux/termux-app#2 SMP PREEMPT Wed Jul 20 23:14:17 KST 2022 aarch64 Android Device manufacturer: samsung Device model: SM-A536U
Android OS version: 11
Device model: samsung:SM-A536U