singlestore-labs / singlestoredb-dev-image

The SingleStoreDB Dev Container is the fastest way to develop with SingleStore on your laptop or in a CI/CD environment.
Apache License 2.0
40 stars 15 forks source link

Improving performance of Singlestore dev docker image on M1/M2 apple machines #45

Open msal-twingo opened 12 months ago

msal-twingo commented 12 months ago

Is your feature request related to a problem? Please describe.

This is a feature request for improving performance of Singlestore dev docker image on M1/M2 apple machines.

In the github page it is described: "In order to support running SingleStoreDB on Apple Silicon many of our performance optimizations are disabled. This can result in unexpectedly bad performance... To tune this performance impact (either faster or slower) you can change the number of cores and amount of RAM..."

Unfortunately the above suggestion seems to be not enough, giving more CPU and RAM to the docker desktop does not help enough and some operations in Singlestore running on M1/M2 machines inside docker desktop still take minutes instead of seconds.

When this docker image is run on Apple M1/M2 machines in a docker desktop, the qemu emulation is used:

image

It seems the emulation automatically chooses a very basic cpu which is missing many of the instructions sets for Singlestore to use:

image

When running sdb-report collect-and-check command inside the docker image shell, you will receive the following notification about missing features of the CPU:

FAIL SSE4.2 CPU extensions unavailable on 127.0.0.1 WARN AVX2 CPU extensions unavailable on 127.0.0.1

image

Describe the solution you'd like As a improvement feature I would like to have the ability to have the docker image with feature instructions Singlestore optimized for. In recent years many developers use Apple M1/M2 machines to work on Singlestore projects and having an optimized environment is very important. This can be via better emulation or via compiling the Singlestore to run natively on such CPU's. I think the above change can improve the performance of the Singlestore docker image.

Describe alternatives you've considered It is possible to control the above manually using for example colima instead of docker desktop (https://github.com/abiosoft/colima) ,which allows to specify parameters for qemu, without modifying the image. Then it is possible to specify which cpu type you would like to simulate for the qemu to use. But, this workaround requires manual and complex steps to make it work.

Additional context Version information: Singlestore 8.1.15 (docker pull ghcr.io/singlestore-labs/singlestoredb-dev:0.2.8) Docker Desktop 4.22 Macbook M1 Pro (Ventura 13.4.1) with 16gb ram 8cores and 10gb allocated for the docker desktop

image image

msal-twingo commented 10 months ago

For whoever following this issue, it seems enabling the experimental feature of Rosetta emulation in docker desktop on M1/M2 is improving the performance in some cases.

I would suggest to try it to see if it helps in your case as a workaround.

You can find this setting under "Settings" > "Features in development" > "Beta features", see screenshot below I tested it on docker desktop version 4.23.0 on M1 machine.

image