You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/testing-with-ryujit.md
+67-13Lines changed: 67 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,8 @@ in case problems occur.
14
14
15
15
**Note** The registry methods below use either `HKEY_LOCAL_MACHINE` or `HKEY_CURRENT_USER`. Using `HKEY_LOCAL_MACHINE` makes the setting applicable to the entire machine and all users. Using `HKEY_CURRENT_USER` makes the setting applicable to just the current user. If using the registry methods, the latter is generally preferable.
16
16
17
+
In general, you should choose the least impactful option. Choose a per-application setting if possible, and only move to a per-user or per-machine setting if necessary. Note that per-application settings are not available for ASP.NET applications.
18
+
17
19
Disable RyuJIT
18
20
==============
19
21
@@ -29,7 +31,7 @@ existing NGEN images that have been compiled by the new JIT continue to be used.
29
31
30
32
<configuration>
31
33
<runtime>
32
-
<useLegacyJit enabled="1">
34
+
<useLegacyJit enabled="1" />
33
35
</runtime>
34
36
</configuration>
35
37
@@ -58,17 +60,9 @@ existing NGEN images that have been compiled by the new JIT continue to be used.
58
60
Disable loading NGEN Images
59
61
===========================
60
62
61
-
If you encounter a bug when you use the new JIT, and if the bug manifests itself
62
-
in an NGEN image, use any of the following methods to force certain named
63
-
assemblies to be recompiled by the JIT and not use the existing native images. You
64
-
will generally pair one of these methods with the same numbered method above to get an NGEN image
65
-
to fall back to JIT compilation, and, in addition, do that JIT compilation with the legacy
66
-
JIT.
63
+
If you encounter a bug when you use the new JIT, and if the bug manifests itself in a function in an NGEN native image (see [here](https://msdn.microsoft.com/en-us/library/6t9t5wcf(v=vs.110).aspx) for details), use any of the following methods to force certain named assemblies to be recompiled by the JIT and not use the existing native images. You will generally pair one of these methods with the same numbered method above to get an NGEN image to fall back to JIT compilation, and, in addition, do that JIT compilation with the legacy JIT.
67
64
68
-
In the examples below, we wish to prevent using the NGEN images of three assemblies, named
69
-
`assembly_one.dll`, `assembly_two.dll`, and `assembly_three.dll`. We specify the assemblies
70
-
using simple assembly names (no public key token, no architecture, and so on). The assembly names
71
-
are specified without using the `.dll` file name extension.
65
+
In the examples below, we wish to prevent using the NGEN images of three assemblies, named `assembly_one.dll`, `assembly_two.dll`, and `assembly_three.dll`. We specify the assemblies using simple assembly names (no public key token, no architecture, and so on). The assembly names are specified without using the `.dll` file name extension.
72
66
73
67
***Method 1: : per-application config file**. Add the following text to the `<app>.exe.config` file. Create
74
68
the indicated sections if they do not already exist.
@@ -103,7 +97,52 @@ are specified without using the `.dll` file name extension.
103
97
Value: assembly_one;assembly_two;assembly_three
104
98
105
99
**Note** This is a semicolon-delimited list of simple assembly names.
100
+
101
+
Disabling the use of all NGEN images
102
+
====================================
103
+
104
+
To prevent any NGEN native image from being used, and force all code to be compiled with the JIT compiler, you can use the ZapDisable configuration variable, as follows. You might choose to do this as an experiment, to see if any NGEN native image contains generated code that is inducing a bug in your application. Generally, if an NGEN native image does have a problem, and the identity of that native image can be determined, using one of the `DisableNativeImageLoadList` mechanisms described above is preferable.
105
+
106
+
**Note** This setting applies to both the 32-bit and 64-bit JIT. Thus, setting this globally will affect all 32-bit .NET applications as well. This is particularly true for **Method 2: environment variable**.
107
+
108
+
**Note 2** NGEN provides significant performance improvements to .NET applications. Disabling the use of NGEN may result in significantly slower application startup times.
109
+
110
+
***Method 1: per-application config file**. Add the following text to the `<app>.exe.config` file. Create
111
+
the indicated sections if they do not already exist.
112
+
113
+
**Note** In this file name, `<app>` represents the actual name of the
114
+
application. So, for example, for `MyApp.exe`, you will have `MyApp.exe.config`.
115
+
116
+
<configuration>
117
+
<runtime>
118
+
<ZapDisable enabled="1" />
119
+
</runtime>
120
+
</configuration>
121
+
122
+
Note that Method 1 does not apply to ASP.NET websites; you cannot use this method in web.config files.
106
123
124
+
This method is preferable as it is scoped to just one application.
125
+
126
+
***Method 2: environment variable**. Set the following environment variable:
127
+
128
+
COMPLUS_ZapDisable=1
129
+
130
+
This method affects any environment that inherits this environment variable. This might be just a single
131
+
console session, or it might affect the entire machine, if you set the environment variable globally.
132
+
133
+
***Method 3: registry**. Using Registry Editor (regedit.exe), find either of the following subkeys:
**Note** Windows has both 32-bit and 64-bit registry sections. The addresses shown above use the 64-bit registry path, so are appropriate for troubleshooting RyuJIT and not affecting 32-bit .NET applications. On a 64-bit machine, the 32-bit registry path for the `HKEY_LOCAL_MACHINE` case is `HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework`.
145
+
107
146
Disable Tail Call Optimization
108
147
==============================
109
148
@@ -123,7 +162,7 @@ You can disable tail call optimization in RyuJIT with the following instructions
123
162
Disabling optimization of a function
124
163
====================================
125
164
126
-
You can selectively disable JIT optimization of a particular function by annotating that function with `MethodImplOptions.NoOptimization`. For example, in C#:
165
+
If you determine that the JIT is incorrectly optimizing a particular function, you can selectively disable JIT optimization for that function by annotating that function with `MethodImplOptions.NoOptimization`. For example, in C#:
127
166
128
167
using System.Runtime.CompilerServices;
129
168
...
@@ -136,7 +175,22 @@ You can selectively disable JIT optimization of a particular function by annotat
136
175
In this case, the annotated `add` function will not be optimized. You can see more detail about `MethodImplAttribute`
Note that this method applies to all .NET JIT compilers.
178
+
This is only effective in solving a code generation problem if the incorrect code being generated by the JIT is due to optimization, as opposed to being due to unoptimized code generation.
179
+
180
+
**Note** This method applies to all .NET JIT compilers.
181
+
182
+
Disabling optimization of all functions
183
+
=======================================
184
+
185
+
While troubleshooting, it might be useful to determine if *any* JIT optimization is causing problems. Instead of using the above `MethodImplAttribute` method above, you can set a single environment variable to disable all JIT optimization. Set this variable:
186
+
187
+
COMPLUS_JitMinOpts=1
188
+
189
+
and run your application.
190
+
191
+
Note that when you run your application under the Visual Studio debugger, it disables JIT optimization by default, to improve the debugging experience. You can read about that [here](https://msdn.microsoft.com/en-us/library/ms241594.aspx).
192
+
193
+
**Note** This method applies to all .NET JIT compilers.
0 commit comments