Skip to main content

SingleStore is now faster on Apple Silicon

laravel-tips  Jack Ellis · Jan 13, 2023

The MacBook Silicon processors are incredible, there's no debate there, and various tools have offered fantastic emulation for arm64 and other processor architectures. The problem is that it's always been slow in some areas. Phase one of us running SingleStore on my MacBook M1 was made possible by work from Charlie Joseph, who managed to get SingleStore running on Docker via emulation. Phase two was made possible by Carl Sverre and his team via the SingleStoreDB Dev Image. And at this point, things were pretty good, but they still needed improvement, as emulation wasn't as fast as we know it could be.

Fast forward to 12th January 2023, and Docker releases BETA support for emulation via Rosetta. We knew this was coming, and I'd been optimistic that performance would improve, and it has. But let's stop with the talking and get to the benchmarks. After all, that's why you're here.

Benchmarks

A few notes for the benchmarks you'll be seeing below:

  1. SingleStore uses something called a query plan cache. Long story short, the first time you run a query, there's a slight lag as SingleStore's engine decides on the BEST way to run the query. The benchmarks are run after that initial query plan cache has run because, in production, this initial query plan cache run is irrelevant.
  2. The benchmark values are an average of 5 runs.
  3. I profiled these queries via SingleStore studio.
  4. I'm running on SingleStore 8.0.4.
  5. My machine is a MacBook Air M1 2020, so many of you will see WAY better performance than me (e.g. if you're on a newer MBA or MBP).
  6. The benchmarks are done in milliseconds, and I've rounded to 2 decimal places.
  7. The benchmarks are not testing for concurrency because this is local development.

Now let's get to testing.

Basic queries

I've performed some basic CRUD queries below and some database creation to see how these behave.

QueryBefore RosettaAfter enabling RosettaHow much faster is Rosetta?
CREATE DATABASE test;3,083 ms2,954.75 ms4.16%
DROP DATABASE test;939 ms740.33 ms21.15%
CREATE TABLE users (id BIGINT AUTO_INCREMENT PRIMARY KEY, name TEXT, email TEXT);121 ms28.75 ms76.24%
INSERT INTO users (id, name, email) VALUES (1, 'Jack Ellis', 'jack.ellis@google-analytics.com');5.4 ms2.66 ms50.74%
SELECT * FROM users WHERE id = 1;4.8 ms2.5 ms47.91%
UPDATE users SET name = 'Jack Google' WHERE id = 1;6 ms3 ms50%
DELETE FROM users WHERE id = 1;5.8 ms2.25 ms61.21%

Aggregations

Now we get into my favourite area, aggregations. I've loaded in 3,564,346 pageviews that belong to usefathom.com (our website). In reality, I wouldn't be using this much data locally unless I was debugging a specific data issue. But I know we'll see the most variance in the benchmarks if I use more data. Clearly, we're not going to get the same performance as when SingleStore is running on intel processors but let's see how things go.

QueryBefore RosettaAfter enabling RosettaHow much faster is Rosetta?
SELECT SUM(pageviews) from pageviews;67.6 ms7.4 ms89%
SELECT pathname, SUM(pageviews) as x from pageviews GROUP BY pathname ORDER BY x DESC LIMIT 100;125.2 ms16.2 ms87%
SELECT pathname, SUM(pageviews) as x FROM pageviews WHERE referrer_hostname = ‘https://laravel.com' GROUP BY pathname ORDER BY x DESC LIMIT 100;133.6 ms12 ms91%
UPDATE pageviews SET utm_campaign = ‘boop’;22,000 ms3,593 ms83.66%
DELETE FROM pageviews WHERE referrer_hostname = 'https://laravel.com';610.33 ms93 ms84.76%
DELETE FROM pageviews;488.5 ms44 ms90.99%

How do I enable Rosetta on Docker?

Easy peasy, simply:

  1. Update to latest Docker
  2. Go into Settings -> Features in development
  3. Tick the “Use Rosetta for x86/amd64 emulation on Apple Silicon

Additional notes

  1. Before enabling Rosetta, the Nodes page in SingleStore studio didn’t work and always showed 0% for both CPU and memory. With Rosetta, it works perfectly.
  2. Performing things such as INSERT INTO pageviews SELECT * FROM pageviews is so much faster when Rosetta is enabled
  3. Member of my SingleStore course, Franco Gilio, profiled and saw huge improvements too. His Laravel Nova searches went from 664ms to 166ms. Incredible.

Not bad

Overall, I’m very impressed by speed improvements. And Docker battery jokes aside, my battery life seems to be doing better. These benchmarks were tested by be manually, and they’re obviously not relevant for production, but I thought they’d be useful to do. I hope this post was helpful. And if you’re not in our community, make sure you check out SingleStore for Laravel, to learn how to use the fastest database in the world with Laravel.

Return to the Fathom Analytics blog

Jack Ellis

BIO
Jack Ellis, CTO + teacher

Pixel cat

Tired of how time consuming and complex Google Analytics can be? Try Fathom Analytics:

Start a free trial

Sign up for our monthly newsletter via email, or grab the RSS feed.