Sign inFree trial
Laravel tips from Fathom

SingleStore is now faster on Apple Silicon

SingleStore is now up to 90.99% faster on your local development environment.

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.

Query Before Rosetta After enabling Rosetta How much faster is Rosetta?
CREATE DATABASE test; 3,083 ms 2,954.75 ms 4.16%
DROP DATABASE test; 939 ms 740.33 ms 21.15%
CREATE TABLE users (id BIGINT AUTO_INCREMENT PRIMARY KEY, name TEXT, email TEXT); 121 ms 28.75 ms 76.24%
INSERT INTO users (id, name, email) VALUES (1, 'Jack Ellis', 'jack.ellis@google-analytics.com'); 5.4 ms 2.66 ms 50.74%
SELECT * FROM users WHERE id = 1; 4.8 ms 2.5 ms 47.91%
UPDATE users SET name = 'Jack Google' WHERE id = 1; 6 ms 3 ms 50%
DELETE FROM users WHERE id = 1; 5.8 ms 2.25 ms 61.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.

Query Before Rosetta After enabling Rosetta How much faster is Rosetta?
SELECT SUM(pageviews) from pageviews; 67.6 ms 7.4 ms 89%
SELECT pathname, SUM(pageviews) as x from pageviews GROUP BY pathname ORDER BY x DESC LIMIT 100; 125.2 ms 16.2 ms 87%
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 ms 12 ms 91%
UPDATE pageviews SET utm_campaign = ‘boop’; 22,000 ms 3,593 ms 83.66%
DELETE FROM pageviews WHERE referrer_hostname = 'https://laravel.com'; 610.33 ms 93 ms 84.76%
DELETE FROM pageviews; 488.5 ms 44 ms 90.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.

Got a question that's not listed here? Send a short email to laravel-tips@usefathom.com.

EU DPA declares Google Analytics illegal because it runs on US cloud providers. Fathom is a Canadian company, and all of your EU traffic never leaves German-owned servers.