termux / proot

An chroot-like implementation using ptrace.
https://wiki.termux.com/wiki/PRoot
Other
761 stars 160 forks source link

Is it possible to give Proot tasks more CPU time? #91

Open JanuszChmiel opened 4 years ago

JanuszChmiel commented 4 years ago

Dear specialists, Is there any way how to give Proot tasks more CPU time or this behaviour is totally driven by Android kernel and can not be changed? Sure, actual CPU time allocation have big advantage. Even intensive apps such as Java virtual machines or C source code compilation process to binary form do not cause Android operating system to become unstable. Users can even work with Adroid multimedia ppps while Proot does its tasks in background. But theoretically. Is it possible to experiment with something to give Proot more CPu priority? If no no problem, I would only like to know.

michalbednarski commented 4 years ago

As far as I know Termux is already handled by Android as foreground process (because it runs foreground service which displays notification) and as far as I know this status also affects apps that run inside Termux (although this can vary between devices)

Another thing is Android may dynamically raise and lower CPU frequency (affecting all processes in system, this can also vary between devices).

I don't really know details but things you could try are:

JanuszChmiel commented 4 years ago

Mr Bednarski, Thank you for wonderful advices. I will apply them. And again thank you for yours complex programmers work on Proot. App is very serious and if some neative thinks are goind on, it display error message even to active Bash shell of Linux distro, which is being executed by it. Very well done.

ghost commented 4 years ago

I'm not sure if it is possible to increase the performance of proot'ed processes without optimizing the proot itself. Due to way how proot works (attaching with ptrace(), hooking/modifying syscalls, etc), it applies significant performance penalty.

You can try to change the priority with utility renice. Example usage:

renice -n -15 $$

- this will increase priority for shell and child processes. You may check man 1 renice for more information about usage.

Plugging in charger

Plugging charger probably will have opposite effect as device will generate more heat (especially if battery is old) and CPU throttling will be activated.

JanuszChmiel commented 4 years ago

Oh yes. renice -n -15 $$ It have really changed process priority. And Android SysuI do not crash and talkback do not freezes while randomly touching The screen.

We do not have The chance to use KQEMu kernel module without rooted Android and The question is, if ARM CPUS, which are inside cheap phones have hardware virtualisation support similar like CPUS which are The parts of IBM/PC compatible machines.

Sure, exclusive CPU access would only have Linux kernel which would operate The device and system resources would not be shared with Android. But this approach has disadvantages. There is no possibility to create something like hardware autodetection for Phone or Tablet boards. There is no PCI so managing autodetection which is being used by Linux live CDS is not applycable for Android phones or tablets.

Sure, C experts can try to analyse Proot source code if some of its parts can be coded better, but Proot have important advantage. It do not creates memory leaks. I have executed Mate desktop and this dekstop run in background for A whole night. I have been afraid, if device will not become unstable during A night. But nothing happened. I could unlock device screen and I could use Mate desktop without issue and without slowdowns after 9 hours.

And no random reboots, no Android werror messages, no too mmuch battery have been discharged.

So I will patiently test Proot. I Am much more sad that Fedora chroots do not use Dbus so effectively like Debian or Arch Linux. As A result, Dbus for Fedora can not be used to run Orca and some apps.