Skip to content

Commit 0d54028

Browse files
committed
mcode map and jit option tweaks
1 parent e79a92b commit 0d54028

3 files changed

Lines changed: 507 additions & 43 deletions

File tree

nattlua.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env luajit
2+
require("nattlua.other.jit_options").SetOptimized()
23
_G.EARLY_STARTUP_TIME = os.clock()
34

45
if select(1, ...) == "profile" and select(2, ...) ~= "trace" then
@@ -39,7 +40,6 @@ if jit and not _G.BUNDLE then
3940
end
4041

4142
require("nattlua.other.lua_compat")
42-
require("nattlua.other.jit_options").SetOptimized()
4343
local m = require("nattlua.init")
4444
package.loaded.nattlua = m
4545

nattlua/other/jit_options.lua

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,21 @@ end
1919
local GC64 = #tostring({}) == 19
2020
-- https://github.com/LuaJIT/LuaJIT/blob/v2.1/src/lj_jit.h#L116-L137
2121
local default_options = {
22-
-- trace cache limits
23-
maxtrace = 1000, -- 1 >= 65535: Max number of traces in cache
24-
maxmcode = 512, -- max total size of all machine code areas (in KBytes).
25-
-- size of each machine code area (in KBytes).
26-
-- See: https://devblogs.microsoft.com/oldnewthing/20031008-00/?p=42223
27-
-- Could go as low as 4K, but the mmap() overhead would be rather high.
22+
maxtrace = 1000,
23+
maxmcode = 512,
2824
sizemcode = jit.os == "Windows" or GC64 and 64 or 32,
29-
-- trace size limits
30-
maxrecord = 4000, -- Max number of recorded IR instructions
31-
maxirconst = 500, -- Max number of IR constants of a trace
32-
maxsnap = 500, -- Max number of snapshots for a trace
33-
-- side trace limits
34-
minstitch = 0, -- Min number of IR instructions for a stitched trace. depends on maxrecord
35-
maxside = 100, -- Max number of side traces of a root trace
36-
-- hotness thresholds
37-
hotloop = 56, -- loop iterations to start a trace (functions need hotloop*2 calls)
38-
hotexit = 10, -- times a trace exit must be taken to start a side trace. depends on maxside
39-
tryside = 4, -- number of attempts to compile a side trace
40-
-- unroll heuristics
41-
instunroll = 4, -- max unroll attempts for loops with instable types.
42-
loopunroll = 15, -- max unroll for loop ops in side traces.
43-
callunroll = 3, -- max depth for recursive calls.
44-
recunroll = 2, -- min unroll for true recursion.
45-
--
25+
maxrecord = 4000,
26+
maxirconst = 500,
27+
maxsnap = 500,
28+
minstitch = 0,
29+
maxside = 100,
30+
hotloop = 56,
31+
hotexit = 10,
32+
tryside = 4,
33+
instunroll = 4,
34+
loopunroll = 15,
35+
callunroll = 3,
36+
recunroll = 2,
4637
}
4738
-- https://github.com/LuaJIT/LuaJIT/blob/v2.1/src/lj_jit.h#L93-L103
4839
local default_flags = {
@@ -121,6 +112,7 @@ function jit_options.Set(options--[[#: AnyTable | nil]], flags--[[#: AnyTable |
121112
end
122113
end
123114

115+
_G.JIT_PARAMS = p
124116
last_options = {options = p, flags = f}
125117
local args = {}
126118

@@ -147,21 +139,29 @@ end
147139
function jit_options.SetOptimized()
148140
jit_options.Set(
149141
{
150-
maxtrace = 65535,
151-
maxmcode = 128000,
152-
sizemcode = 256,
153-
minstitch = 1,
154-
maxrecord = 50000,
155-
maxirconst = 8000,
156-
maxside = 100,
157-
maxsnap = 100,
158-
hotloop = 5,
159-
hotexit = 100,
160-
tryside = 1,
161-
instunroll = 1100,
162-
loopunroll = 1110,
163-
callunroll = 1110,
164-
recunroll = 1110,
142+
-- trace cache limits
143+
maxtrace = 65535, -- default: 1000 | 1 >= 65535: Max number of traces in cache
144+
maxmcode = 128000, -- default: 512 | max total size of all machine code areas (in KBytes).
145+
-- size of each machine code area (in KBytes).
146+
-- See: https://devblogs.microsoft.com/oldnewthing/20031008-00/?p=42223
147+
-- Could go as low as 4K, but the mmap() overhead would be rather high.
148+
sizemcode = 64, -- default: jit.os == "Windows" or GC64 and 64 or 32
149+
-- trace size limits
150+
maxrecord = 8000, -- default: 4000 | Max number of recorded IR instructions
151+
maxirconst = 2000, -- default: 500 | Max number of IR constants of a trace
152+
maxsnap = 1000, -- default: 500 | Max number of snapshots for a trace
153+
-- side trace limits
154+
minstitch = 0, -- default: 0 | Min number of IR instructions for a stitched trace. depends on maxrecord
155+
maxside = 10, -- default: 100 | Max number of side traces of a root trace
156+
-- hotness thresholds
157+
hotloop = 10000, -- default: 56 | loop iterations to start a trace (functions need hotloop*2 calls)
158+
hotexit = 0, -- default: 10 | times a trace exit must be taken to start a side trace. depends on maxside
159+
tryside = 0, -- default: 4 | number of attempts to compile a side trace
160+
-- unroll heuristics
161+
instunroll = 0, -- default: 4 | max unroll attempts for loops with instable types.
162+
loopunroll = 1000, -- default: 15 | max unroll for loop ops in side traces.
163+
callunroll = 300, -- default: 3 | max depth for recursive calls.
164+
recunroll = 0, -- default: 2 | min unroll for true recursion.
165165
},
166166
{
167167
fold = true,

0 commit comments

Comments
 (0)