cyberkernelofficial / docker-in-termux

This repository contains instructions on how to install Docker in Termux, without root.
MIT License
151 stars 17 forks source link

Qemu only uses 2 cores and 1G of memory #11

Open Eboubaker opened 3 months ago

Eboubaker commented 3 months ago

My phone has 8 cores and 8G of memory but when running lscpu and free -h in the alpine box it shows 2 cores and 1G of memory can you modify the qemu run command so that it uses all available resources?

Eboubaker commented 3 months ago

For now i had to modify the qemu run command

mem=$(free -m | grep -oP '\d+' | head -n 1)
cpus=$(nproc)
qemu-system-x86_64 -machine q35 -m $mem -smp cpus=$cpus -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -nographic alpine.img

I wanted you to change it in the readme to be the default, the emulation was very slow before i changed this.

cyberkernelofficial commented 3 months ago

Thanks for the feedback! While increasing resources can improve performance for some users, it's not necessary for everyone. The default configuration aims for wider compatibility. We can definitely add your script as an optional optimization in the README for users who want to utilize more resources. Would you like to contribute by submitting a pull request with this information?

lexavey commented 2 months ago

Termux bench

~/sysbench $ sysbench cpu run
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time

Prime numbers limit: 10000

Initializing worker threads...

Threads started!

CPU speed:
    events per second: 753647.69

Throughput:
    events/s (eps):                      753647.6891
    time elapsed:                        10.0008s
    total number of events:              7537057

Latency (ms):
         min:                                    0.00
         avg:                                    0.00
         max:                                    0.33
         95th percentile:                        0.00
         sum:                                 2695.12

Threads fairness:
    events (avg/stddev):           7537057.0000/0.00
    execution time (avg/stddev):   2.6951/0.00

Default docker

alpine:~# sysbench cpu run
sysbench 1.0.20 (using system LuaJIT 2.1.1710398010)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time

Prime numbers limit: 10000

Initializing worker threads...

Threads started!

CPU speed:
    events per second:    31.17

General statistics:
    total time:                          10.0382s
    total number of events:              315

Latency (ms):
         min:                                   27.69
         avg:                                   31.26
         max:                                   49.39
         95th percentile:                       39.65
         sum:                                 9847.27

Threads fairness:
    events (avg/stddev):           315.0000/0.00
    execution time (avg/stddev):   9.8473/0.00

Docker with unlocked cpu and mem

alpine:~# sysbench cpu run
sysbench 1.0.20 (using system LuaJIT 2.1.1710398010)

Running the test with following options:
Number of threads: 1
Initializing random number generator from current time

Prime numbers limit: 10000

Initializing worker threads...

Threads started!

CPU speed:
    events per second:    34.42

General statistics:
    total time:                          10.0125s
    total number of events:              347

Latency (ms):
         min:                                   27.04
         avg:                                   28.50
         max:                                   40.94
         95th percentile:                       30.26
         sum:                                 9890.67

Threads fairness:
    events (avg/stddev):           347.0000/0.00
    execution time (avg/stddev):   9.8907/0.00

Yea still low speed, my nproc=6,mem=2806