This commit is contained in:
Maxime Chevalier-Boisvert 2023-10-10 13:10:47 -04:00 коммит произвёл GitHub
Родитель 5cc44f48c5
Коммит a6d190fa4d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 6 добавлений и 5 удалений

Просмотреть файл

@ -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.