planck-repl / planck

Stand-alone ClojureScript REPL
https://planck-repl.org
Eclipse Public License 1.0
1.03k stars 68 forks source link

Seems oddly slow on Apple M1 with Rosetta #1050

Closed kkinnear closed 3 years ago

kkinnear commented 3 years ago

I have been using Planck on a MacBook Air mid-2012 for years, and it has been great! Thanks for all the work to make it possible!

I am in the process of upgrading to a new MacBook Air M1. I have found that, generally, things running with Rosetta run faster than they did on the old 2012 Air. Planck, however, not so much. The good news -- it does work, and comes up quickly -- quickly enough that I can't perceive any realistic difference between the platforms.

However, when loading my program (require 'zprint.core :reload) using

planck -c `lein classpath` -r

on both platforms, I am seeing a considerable difference in times:

                                    planck           cljs
2012 MA x86_64:          54s        2.24.0         1.10.520
2020 MA M1:           2m 11s        2.25.0         1.10.597

This is clearly not apples to apples (so to speak). I haven't upgraded the old laptop to the latest Planck since I still need it for some things that don't work yet on the new M1 chip (like GraalVM linux builds with docker) and don't want to lose the better Planck performance in the off chance that this isn't the M1 chip but, rather, the move from 2.24.0 to 2.25.0.

This isn't a show stopper for me -- mostly I'm using Planck for my cljs tests at present, so I can just do something else while I run them. If it gets too annoying, I can use the old laptop or I can try to figure out how to build a native Planck, which would no doubt be an opportunity to learn about a lot of things I don't yet know about.

I just wanted to mention this in passing, to pass the information along and to see if this seems wildly off base to you.

Thanks again for Planck! It has been (and continues to be) an important part of my development toolset!

mfikes commented 3 years ago

It would be interesting to see if Planck is fast on an M1 if it is built targeting that CPU architecture.

kkinnear commented 3 years ago

I completely agree. I haven't attempted to build it because, never having done so before or even having the necessary tools currently installed, I expect I'm looking at decent chunk of time to even try to pull it off. As I'm struggling to get a release of zprint out, I'm trying to stay focused on that instead of the myriad of fascinating things that beckon for my attention, this certainly being one of them. However, given that nobody has chimed in on this one for a couple of months, I'll bump it up higher on my list of things to investigate and let you know what I find out when I give it a try.

mfikes commented 3 years ago

Ahh, interestingly, it looks like Planck binaries are available for "Apple Silicon" via homebrew: https://formulae.brew.sh/formula/planck

Perhaps all that is needed is a brew uninstall and reinstall. Dunno how that works with homebrew.

kkinnear commented 3 years ago

After fiddling around with Homebrew a bit, I was able to give both versions a try. Both Plancks were installed with Homebrew, and both identified themselves as:

 % planck -V
2.25.0

These times are what it took to load the current version of zprint. The code differs a good bit from what I used above, but the actual commands to load it were identical.

                                 planck          cljs
2020 MA M1: Rosetta    3m 13s    2.25.0        1.10.597
2020 MA M1: ARM           22s    2.25.0        1.10.597

I'm a bit surprised that it took so much longer to load using the Planck that uses Rosetta today then it did above in January, because the code doesn't seem to me to be that different, but the environment on the laptop is certainly different, with different things running and consuming memory. The two numbers in this comment were run seconds apart, so at least they are comparable. In addition, I ran the Rosetta version twice and got about the same number each time.

Overall, this is extremely good news -- the ARM version of Planck runs very well!

The reason why this matters to me is because Planck is integral to the zprint cljs tests. Here are the times to run the zprint tests on my 2020 MacBook Air M1:

planck Rosetta:   clj -A:cljs-runner  702.34s user 7.51s system 102% cpu 11:31.39 total
planck ARM:       clj -A:cljs-runner   93.97s user 3.36s system 125% cpu  1:17.83 total

which is a considerable difference.

Planck is certainly entirely usable now with the ARM version. Thanks very much for alerting me to its existence!