3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

「Apple Silicon ネイティブが Rosetta 2 より遅い」とはならなくなった

Last updated at Posted at 2024-12-28

これは何?

という記事を書いたんだけど、この記事を書いた時点では

ruby
N=10000
r=(1..N).max_by{ |x| ((N-x)**x/7) % 6074001001 }
p r

という計算は、ARM64 版 の ruby で動かすより、Rosetta 2 上で x86_64 版を動かしたほうが速いという結果になっていた。

で、今はどうなってるの? という話。

環境

使った ruby は、以下の 8個。

  • ruby 3.1.5p252 (2024-04-23 revision 1945f8dc0e) [x86_64-darwin24]
  • ruby 3.1.6p260 (2024-05-29 revision a777087be6) [arm64-darwin24]
  • ruby 3.2.5 (2024-07-26 revision 31d0f1a2e7) [x86_64-darwin24]
  • ruby 3.2.6 (2024-10-30 revision 63aeb018eb) [arm64-darwin24]
  • ruby 3.3.5 (2024-09-03 revision ef084cc8f4) [x86_64-darwin24]
  • ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [arm64-darwin24]
  • ruby 3.4.0dev (2024-12-25 master f450108330) +PRISM [x86_64-darwin24]
  • ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [arm64-darwin24]

ハードウェアは同一で、MacBook Pro M1 非Max。

x86_64 版と arm64 版のバージョンが合ってないのは良くないわけだけど、サボった。

時間の測定は time コマンドなんだけど、time の前に一回動かしている。

結果

結果は以下の通り。

image.png

arm64 版は、3.2 → 3.3 でなにかあったらしく、3倍ぐらい速くなっている。すごい。

ちなみに

ちなみに同種の計算

python
N=10000
r=0
m=0
for x in range(1,N+1):
    n=((N-x)**x//7) % 6074001001
    if m<n:
        r=x
        m=n
print(r)

を Python 3.13.1 で行うと

$ python3.13 -V -V                                                             
Python 3.13.1 (main, Dec  3 2024, 17:59:52) [Clang 16.0.0 (clang-1600.0.26.4)]

$ python3.13 -c "import platform;print(platform.machine(), platform.version())"
arm64 Darwin Kernel Version 24.2.0: Fri Dec  6 19:01:59 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6000

$ python3.13 python/test.py 
8663

$ /usr/bin/time -h python3.13 python/test.py
8663
        4.55s real              4.53s user              0.01s sys       

という感じ。

まとめ

以前

今遅いものもそのうち早くなるんじゃないかと思うよ(思うだけ)。

と書いたけど、やはりそうなった。
開発者の皆様ありがとうございます。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?