utmapp / UTM

Virtual machines for iOS and macOS
https://getutm.app
Apache License 2.0
26.23k stars 1.32k forks source link

The possibility to speed up UTM SE by WKWebView. #6501

Open KusakabeShi opened 1 month ago

KusakabeShi commented 1 month ago

JIT is not allowed in iOS, but the javascript engine itself is JIT enabled.

I found a project called jslinux, which is basically run qemu in browser engine, which enables JIT technology I think.

And I write a simple python benchmark, test it on jslinux and UTM SE

This is jslinux running in Google Chrome in iOS 17: image

This is UTM SE downloaded from App store: image

The jslinux(32s) is faster than UTM SE(62s).
Although the cpu architecture is different(risc-v/aarch64), so that the result is not direct comparable.

But I'm curious do we have the possibility to speedup UTM SE by running qumu in the WKWebView in iOS?

The script:

#!/usr/bin/python3
#Python CPU Benchmark by Alex Dedyura (Windows, macOS, Linux)

import time
import platform
import subprocess

print('Python CPU Benchmark by Alex Dedyura (Windows, macOS(Darwin), Linux)')
print('Arch: ' + subprocess.run(['uname', '-a'], capture_output=True, text=True).stdout,end="")
print('Python: ' + platform.python_version())

print('\nBenchmarking: \n')

start_benchmark = 100  # The number of iterations in each test
repeat_benchmark = 0    # The number of repetitions of the test
max_repeat_benchmark = 10    # The number of repetitions of the test
max_time = 12
# Initializing a variable to accumulate execution time
total_duration = 0

start_s = time.perf_counter()
# Starting the test cycle
for attempt in range(max_repeat_benchmark):
    repeat_benchmark += 1
    start = time.perf_counter()  # Recording the initial time

    # Nested loops for performing calculations
    for i in range(start_benchmark):
        for x in range(1, 1000):
            3.141592 * 2 ** x  # Multiplying the number Pi by 2 to the power of xx
        for x in range(1, 10000):
            float(x) / 3.141592  # Dividing x by Pi
        for x in range(1, 10000):
            float(3.141592) / x  # Dividing the number Pi by x

    end = time.perf_counter()  # Recording the end time
    duration = round(end - start, 3)  # Calculate and round up the execution time
    total_duration += duration  # Adding the execution time to the total amount
    print(f'Time: {duration}s')  # We output the execution time for each iteration
    if total_duration > max_time:
        break
# Calculate and output the average execution time
average_duration = round(total_duration / repeat_benchmark, 3)
print(f'Average (from {repeat_benchmark} repeats): {average_duration}s')
itjustcrashed commented 1 month ago

This is genuinely a smart idea.

osy commented 1 month ago

This was looked into before and I think it's just too much work to integrate. If someone volunteers to make a fork, we will maintain it when it works. This was how UTM SE came into being.

SkywalkerIron commented 1 month ago

it‘s a great idea

sinoru commented 1 month ago

As I know, JSCore does not allow JIT on iOS, iPadOS still now. https://forums.developer.apple.com/forums/thread/746159