[前][次][番号順一覧][スレッド一覧]

ruby-changes:69205

From: Maxime <ko1@a...>
Date: Thu, 21 Oct 2021 08:20:02 +0900 (JST)
Subject: [ruby-changes:69205] 4f24f3afc7 (master): Update README.md

https://git.ruby-lang.org/ruby.git/commit/?id=4f24f3afc7

From 4f24f3afc7baed2294614357486e10e1f055c661 Mon Sep 17 00:00:00 2001
From: Maxime Chevalier-Boisvert <maximechevalierb@g...>
Date: Thu, 6 May 2021 15:31:38 -0400
Subject: Update README.md

---
 README.md | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index fcadb3edc6..76b9ba40d3 100644
--- a/README.md
+++ b/README.md
@@ -86,10 +86,25 @@ YJIT supports all command-line options supported by upstream CRuby, but also add https://github.com/ruby/ruby/blob/trunk/README.md#L86
  - `--yjit-version-limit=N`: maximum number of versions to generate per basic block (default 4)
  - `--yjit-greedy-versioning`: greedy versioning mode (disabled by default, may increase code size)
 
-## Benchmarking
+### Benchmarking
 
 We have collected a set of benchmarks and implemented a simple benchmarking harness in the [yjit-bench](https://github.com/Shopify/yjit-bench) repository. This benchmarking harness is designed to disable CPU frequency scaling, set process affinity and disable address space randomization so that the variance between benchmarking runs will be as small as possible. Please kindly note that we are at an early stage in this project.
 
+## Performance Tips
+
+This section contains tips on writing Ruby code that will run fast on YJIT. Some of this advice is based on current limitations of YJIT, while other advice is broadly applicable. It may not be practical to apply these tips everywhere in your codebase, but you can profile your code using a tool such as [stackprof](https://github.com/tmm1/stackprof) and the specific methods that make up the largest fractions of the execution time.
+
+- Use exceptions for error recovery only, not as part of normal control-flow
+- Avoid redefining basic integer operations (i.e. +, -, <, >, etc.)
+- Avoid redefining the meaning of `nil`, equality, etc.
+- Use while loops if you can, instead of `integer.times`
+- Minimize layers of indirection
+  - Avoid classes that wrap objects if you can
+  - Avoid methods that just call another method, trivial one liner methods
+- CRuby method calls are costly. Favor larger methods over smaller methods.
+
+You can also compile YJIT in debug mode and use the `--yjit-stats` command-line option to see which bytecodes cause YJIT to exit, and refactor your code to avoid using these instructions in the hottest methods of your code.
+
 ## Source Code Organization
 
 The YJIT source code is divided between:
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]