aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>2023-10-10 13:10:47 -0400
committerGitHub <noreply@github.com>2023-10-10 13:10:47 -0400
commita6d190fa4d33a848f063c3eec035035e34e55998 (patch)
tree11fd59d30b90e129d3d716403324c087f0d55c2c /doc
parent5cc44f48c51974a84a40480477a4afd8901ae7e4 (diff)
downloadruby-a6d190fa4d33a848f063c3eec035035e34e55998.tar.gz
Update yjit.md
Diffstat (limited to 'doc')
-rw-r--r--doc/yjit/yjit.md11
1 files changed, 6 insertions, 5 deletions
diff --git a/doc/yjit/yjit.md b/doc/yjit/yjit.md
index 41fd742423..c3fc4fc9d6 100644
--- a/doc/yjit/yjit.md
+++ b/doc/yjit/yjit.md
@@ -87,7 +87,7 @@ The YJIT `ruby` binary can be built with either GCC or Clang. It can be built ei
# Configure in release mode for maximum performance, build and install
./autogen.sh
./configure --enable-yjit --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc
-make -j install
+make -j && make install
```
or
@@ -96,7 +96,7 @@ or
# Configure in lower-performance dev (debug) mode for development, build and install
./autogen.sh
./configure --enable-yjit=dev --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc
-make -j install
+make -j && make install
```
Dev mode includes extended YJIT statistics, but can be slow. For only statistics you can configure in stats mode:
@@ -105,7 +105,7 @@ Dev mode includes extended YJIT statistics, but can be slow. For only statistics
# Configure in extended-stats mode without slow runtime checks, build and install
./autogen.sh
./configure --enable-yjit=stats --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc
-make -j install
+make -j && make install
```
On macOS, you may need to specify where to find some libraries:
@@ -117,7 +117,7 @@ brew install openssl libyaml
# Configure in dev (debug) mode for development, build and install
./autogen.sh
./configure --enable-yjit=dev --prefix=$HOME/.rubies/ruby-yjit --disable-install-doc --with-opt-dir="$(brew --prefix openssl):$(brew --prefix readline):$(brew --prefix libyaml)"
-make -j install
+make -j && make install
```
Typically configure will choose the default C compiler. To specify the C compiler, use
@@ -242,6 +242,7 @@ Running code GC adds overhead, but it could be still faster than recovering from
This section contains tips on writing Ruby code that will run as fast as possible on YJIT. Some of this advice is based on current limitations of YJIT, while other advice is broadly applicable. It probably won't be practical to apply these tips everywhere in your codebase. You should ideally start by profiling your application using a tool such as [stackprof](https://github.com/tmm1/stackprof) so that you can determine which methods make up most of the execution time. You can then refactor the specific methods that make up the largest fractions of the execution time. We do not recommend modifying your entire codebase based on the current limitations of YJIT.
+- Avoid using `OpenStruct`
- Avoid redefining basic integer operations (i.e. +, -, <, >, etc.)
- Avoid redefining the meaning of `nil`, equality, etc.
- Avoid allocating objects in the hot parts of your code
@@ -249,7 +250,7 @@ This section contains tips on writing Ruby code that will run as fast as possibl
- Avoid classes that wrap objects if you can
- Avoid methods that just call another method, trivial one liner methods
- Try to write code so that the same variables always have the same type
-- Use while loops if you can, instead of C methods like `Array#each`
+- Use `while` loops if you can, instead of C methods like `Integer#times` and `Array#each`
- This is not idiomatic Ruby, but could help in hot methods
- CRuby method calls are costly. Avoid things such as methods that only return a value from a hash or return a constant.