YJIT ã® Rust å®è£ ããã¼ã¸ããã¾ããããã¾ã®ã¨ããä»å¹´ã® Shopify ããã®ä»£è¡¨ä½ã§ã¯ã¨è¦ã¦ãã¾ã (YJIT èªä½ã¯ Ruby 3.1 㧠C å®è£ å°å ¥ããã¦ããæ©è½ã§ã) ã
ããããããã§ãç¾å¨ã® Ruby 3.2.0dev 㧠YJIT ãæå¹ã«ããå ´åã¯ãRust ã®å¦çç³» (1.60.0 1.58.1 以ä¸) ãå¿
è¦ã«ãªãã¾ããRust ã®ã¤ã³ã¹ãã¼ã«ã«ä½¿ã rustup
ã«ã¤ãã¦ã¯ä»¥ä¸ã®å
¬å¼ãã¼ã¸ãªã©ãåç
§ãã¦ãã ããã
YJIT ã¯ããã©ã«ãã§ã¯ãã«ãããã¾ãã (ãªã®ã§ YJIT ã使ããªããã«ãã§ããã° Rust å¦çç³»ã¯ä¸è¦ã§ã) ã
ããã©ã«ãã® YJIT ãªãã® Ruby ããã«ããã¦ããå ´å㯠--yjit
ãªãã·ã§ã³ã渡ãã¦ããruby: warning: Ruby was built without YJIT support
ã¨ä»¥ä¸ã®ããã«è¦åãåºåããã¾ããYJIT ã® API ã¯åå¨ããªãã®ã§ã使ããã¨ããã¨ã¨ã©ã¼ã«ãªãã¾ãã
% ruby --yjit -e 'p RubyVM::YJIT.enabled?' ruby: warning: Ruby was built without YJIT support -e:1:in `<main>': uninitialized constant RubyVM::YJIT (NameError) p RubyVM::YJIT.enabled? ^^^^^^
ãã®ããã Ruby 3.1 ã¨ç°ãªãããã©ã«ã (ã®ãã«ã) æåãªã®ã§ãYJIT ãæå¹ã«ãã¦ããã¦ã¼ã¶ã¼ã¯æ°ã«çãã¦ããã¨è¯ãããã§ãã
% ruby --yjit -ve 'p RubyVM::YJIT.enabled?' ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) +YJIT [x86_64-darwin19] true
Ruby 3.2.0dev ã«ããã¦ãYJIT è¾¼ã¿ã§ Ruby æ¬ä½ããã«ãããå ´åã¯ä»¥ä¸ã®ããã« ./configre
ã«ãªãã·ã§ã³ã渡ãã¾ãã
% ./autogen.sh % ./configure --enable-yjit=dev ... % make -j install building Rust YJIT (dev mode) % ruby --yjit -ve 'p RubyVM::YJIT.enabled?' ruby 3.2.0dev (2022-04-27T15:00:54Z master b43eb54a0c) +YJIT [x86_64-darwin19] true
ãªãªã¼ã¹ã¢ã¼ã --enable-yjit
ã¨ãããã°éçºã¢ã¼ã --enable-yjit=dev
ã§ãªãã·ã§ã³ãç°ãªãã¾ãã詳ããã¯ããã¥ã¡ã³ããåç
§ãã¦ãã ããã
rbenv ã使ã£ã¦ããããã§ããã°ãç°å¢å¤æ° RUBY_CONFIGURE_OPTS
ã使ã£ããªãã·ã§ã³æ¸¡ããææ©ãã§ãã
% RUBY_CONFIGURE_OPTS=--enable-yjit rbenv install 3.2.0-dev % ruby --yjit -ve 'p RubyVM::YJIT.enabled?' ruby 3.2.0dev (2022-04-27T15:00:54Z master b43eb54a0c) +YJIT [x86_64-darwin19] true
ããã« Ruby ã®ã©ã³ã¿ã¤ã ã§ã YJIT ã¯ããã©ã«ãç¡å¹ãªã®ã§ãYJIT ãæå¹åããå ´å㯠ruby
ã³ãã³ãã®ãªãã·ã§ã³ã« --yjit
ã渡ãããç°å¢å¤æ° RUBY_YJIT_ENABLE=1
ãªããã渡ãã¾ããç´æ¥ ruby
ã³ãã³ãã使ããã« rake
çµç±ãªããã§å®è¡ããå ´åã¯ç°å¢å¤æ°ã®æå®æ¹æ³ã使ããã¨ã«ãªãã¨æãã¾ãã
ãã¨å½ç¶ã§ãããRuby ã®ãã«ãç°å¢ã« Rust ãã¤ã³ã¹ãã¼ã«ããã¦ããªããã°ãYJIT æå¹ã®ãã«ãæã«ä»¥ä¸ã®ãããªã¨ã©ã¼ã«ãªãã¾ãã
% RUBY_CONFIGURE_OPTS=--enable-yjit rbenv install 3.2.0-dev (snip) Last 10 log lines: checking whether -pie is accepted as LDFLAGS... yes checking whether wrapper for LD_LIBRARY_PATH is needed... no checking whether dtrace USDT is available... no checking for __builtin_setjmp... yes with cast () checking for _setjmpex as a macro or function... no checking for _setjmp as a macro or function... yes checking for sigsetjmp as a macro or function... no checking for setjmp type... __builtin_setjmp checking for rustc... no configure: error: rustc is required. Installation instructions available at https://www.rust-lang.org/tools/install
Rust å¦çç³»ãã¤ã³ã¹ãã¼ã«ãã¾ãããã
ã³ã¼ãçã«ã¯ ruby/yjit ãã£ã¬ã¯ããªä»¥ä¸ããRust ã®ä¸çã«ãªã£ã¦ããããã§ãèå³ã®ãã人ã¯è¦ã¦ã¿ãã¨çºè¦ãããããããã¾ããã
RubyGems ã«ã Rust æ¡å¼µã«åãã Cargo ãã«ãã¼ããã¼ã¸ããããã¨ããããRuby ã¨ã³ã·ã¹ãã 㨠Rust ã¨ã®é¢ãããä»å¾ã®é¢å¿ã©ããã§ãã
ãããã£ãæµããããã®ã§ãå人çã«ã¯ The Rust Programming Language (æ¥æ¬èªè¨³) ã®å¾ã«ãããã°ã©ãã³ã° Rust 第2çããèªãã§ããã¨ããã§ãããçãæã«æãå±ãæãã§ããããã§ã (å ã« The Rust Programming Language ã§å ¨ä½ã®é°å²æ°ãæ´ãã§ããã¨ç解ãã¹ã ã¼ã¹ãã) ã
ð¦