Skip to content

Commit 50f35b6

Browse files
committed
Reasonable performance with time budgeting call sites...
... and reasonable results without aborting
1 parent f183577 commit 50f35b6

File tree

5 files changed

+96
-91
lines changed

5 files changed

+96
-91
lines changed

results.md

Lines changed: 63 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,119 @@
1-
Julia Version 1.7.0
2-
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
1+
Julia Version 1.8.0-DEV.1169
2+
Commit f2f31336a1 (2021-12-22 11:27 UTC)
33
Platform Info:
44
OS: Windows (x86_64-w64-mingw32)
55
CPU: Intel(R) Core(TM) i7-10710U CPU @ 1.10GHz
66
WORD_SIZE: 64
77
LIBM: libopenlibm
88
LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
9-
Environment:
10-
JULIA_EDITOR = code
11-
JULIA_NUM_THREADS = 5
12-
Test run at: 2021-12-12T01:39:18.353
9+
Test run at: 2021-12-23T13:30:26.035
1310

1411
Maximum number of statements per lowered expression: 10000000
1512

1613
| Test file | Passes | Fails | Errors | Broken | Aborted blocks |
1714
| --------- | ------:| -----:| ------:| ------:| --------------:|
18-
| ambiguous | 105 | 0 | 1 | 2 | 14 |
19-
| compiler/inference | 1003 | 5 | 2 | 2 | 3 |
20-
| compiler/validation | 24 | 0 | 1 | 0 | 0 |
21-
| compiler/ssair | X | X | X | X | X |
22-
| compiler/irpasses | 25 | 0 | 0 | 0 | 1 |
23-
| compiler/codegen | X | X | X | X | X |
24-
| compiler/inline | 63 | 2 | 0 | 1 | 0 |
25-
| compiler/contextual | 9 | 2 | 1 | 0 | 0 |
26-
| subarray | 326868 | 0 | 0 | 0 | 2 |
27-
| strings/basic | 87674 | 0 | 0 | 0 | 2 |
28-
| strings/search | 692 | 0 | 0 | 0 | 0 |
29-
| strings/util | 619 | 0 | 0 | 0 | 0 |
30-
| strings/io | 12764 | 0 | 0 | 0 | 1 |
31-
| strings/types | 2302691 | 0 | 0 | 0 | 2 |
15+
| ambiguous | 107 | 0 | 0 | 2 | 0 |
16+
| subarray | 318316 | 0 | 0 | 0 | 0 |
17+
| strings/basic | 87674 | 0 | 0 | 0 | 0 |
18+
| strings/search | 876 | 0 | 0 | 0 | 0 |
19+
| strings/util | 1147 | 0 | 0 | 0 | 0 |
20+
| strings/io | 12764 | 0 | 0 | 0 | 0 |
21+
| strings/types | 2302691 | 0 | 0 | 0 | 0 |
3222
| unicode/utf8 | 19 | 0 | 0 | 0 | 0 |
3323
| core | X | X | X | X | X |
34-
| worlds | X | X | X | X | X |
24+
| worlds | ☠️ | ☠️ | ☠️ | ☠️ | ☠️ |
3525
| atomics | 3444 | 0 | 0 | 0 | 0 |
3626
| keywordargs | 151 | 0 | 0 | 0 | 0 |
37-
| numbers | 1622626 | 0 | 0 | 1 | 8 |
38-
| subtype | X | X | X | X | X |
39-
| char | 1623 | 0 | 0 | 0 | 0 |
27+
| numbers | 1578757 | 1 | 0 | 2 | 0 |
28+
| subtype | 337674 | 0 | 0 | 19 | 0 |
29+
| char | 1628 | 0 | 0 | 0 | 0 |
4030
| triplequote | 29 | 0 | 0 | 0 | 0 |
4131
| intrinsics | 301 | 0 | 0 | 0 | 0 |
42-
| dict | X | X | X | X | X |
43-
| hashing | 12519 | 0 | 0 | 0 | 1 |
44-
| iobuffer | 205 | 0 | 0 | 0 | 0 |
45-
| staged | 58 | 6 | 0 | 0 | 0 |
46-
| offsetarray | 465 | 11 | 6 | 3 | 1 |
47-
| arrayops | 2013 | 0 | 0 | 2 | 3 |
48-
| tuple | 606 | 0 | 0 | 0 | 0 |
49-
| reduce | X | X | X | X | X |
50-
| reducedim | 865 | 0 | 0 | 0 | 1 |
51-
| abstractarray | 1838 | 0 | 0 | 0 | 3 |
52-
| intfuncs | 215864 | 0 | 0 | 0 | 1 |
32+
| dict | 144420 | 0 | 0 | 0 | 0 |
33+
| hashing | 12519 | 0 | 0 | 0 | 0 |
34+
| iobuffer | 209 | 0 | 0 | 0 | 0 |
35+
| staged | 59 | 5 | 0 | 0 | 0 |
36+
| offsetarray | 484 | 3 | 0 | 3 | 0 |
37+
| arrayops | 2031 | 0 | 0 | 2 | 0 |
38+
| tuple | 625 | 0 | 0 | 0 | 0 |
39+
| reduce | 8580 | 2 | 0 | 0 | 0 |
40+
| reducedim | 865 | 0 | 0 | 0 | 0 |
41+
| abstractarray | 55892 | 0 | 0 | 24795 | 0 |
42+
| intfuncs | 227902 | 0 | 0 | 0 | 0 |
5343
| simdloop | 240 | 0 | 0 | 0 | 0 |
5444
| vecelement | 678 | 0 | 0 | 0 | 0 |
55-
| rational | 98634 | 0 | 0 | 1 | 1 |
56-
| bitarray | 652056 | 0 | 3658 | 0 | 14 |
45+
| rational | 98639 | 0 | 0 | 1 | 0 |
46+
| bitarray | 914001 | 1 | 0 | 0 | 0 |
5747
| copy | 533 | 0 | 0 | 0 | 0 |
58-
| math | 148737 | 0 | 1 | 0 | 3 |
48+
| math | 148967 | 1 | 11 | 0 | 0 |
5949
| fastmath | 946 | 0 | 0 | 0 | 0 |
6050
| functional | 98 | 0 | 0 | 0 | 0 |
61-
| iterators | 10080 | 0 | 0 | 0 | 2 |
62-
| operators | 13039 | 0 | 0 | 0 | 0 |
63-
| ordering | 35 | 0 | 0 | 0 | 0 |
64-
| path | 1295 | 0 | 0 | 12 | 1 |
51+
| iterators | 10164 | 0 | 0 | 0 | 0 |
52+
| operators | 13039 | 0 | 1 | 0 | 0 |
53+
| ordering | 37 | 0 | 0 | 0 | 0 |
54+
| path | 1051 | 0 | 0 | 12 | 0 |
6555
| ccall | X | X | X | X | X |
66-
| parse | 16098 | 0 | 0 | 0 | 1 |
67-
| loading | X | X | X | X | X |
68-
| gmp | 2323 | 1 | 0 | 0 | 1 |
69-
| sorting | 12705 | 0 | 3 | 10 | 4 |
70-
| spawn | 209 | 1 | 1 | 4 | 0 |
71-
| backtrace | 8 | 11 | 17 | 1 | 0 |
72-
| exceptions | 38 | 25 | 7 | 0 | 0 |
56+
| parse | 16098 | 0 | 0 | 0 | 0 |
57+
| loading | 168472 | 2 | 1 | 0 | 0 |
58+
| gmp | 2357 | 0 | 0 | 0 | 0 |
59+
| sorting | 16096 | 0 | 0 | 10 | 0 |
60+
| spawn | 230 | 1 | 1 | 4 | 0 |
61+
| backtrace | 13 | 9 | 16 | 1 | 0 |
62+
| exceptions | 43 | 21 | 6 | 0 | 0 |
7363
| file | X | X | X | X | X |
74-
| read | X | X | X | X | X |
64+
| read | 3870 | 0 | 0 | 0 | 0 |
7565
| version | 2452 | 0 | 0 | 0 | 0 |
76-
| namedtuple | 214 | 0 | 0 | 0 | 0 |
77-
| mpfr | 1127 | 0 | 0 | 1 | 0 |
78-
| broadcast | 507 | 1 | 0 | 0 | 2 |
79-
| complex | 8432 | 0 | 0 | 5 | 1 |
66+
| namedtuple | 215 | 0 | 0 | 0 | 0 |
67+
| mpfr | 1135 | 0 | 0 | 1 | 0 |
68+
| broadcast | 509 | 2 | 0 | 0 | 0 |
69+
| complex | 8432 | 0 | 0 | 5 | 0 |
8070
| floatapprox | 49 | 0 | 0 | 0 | 0 |
8171
| reflection | X | X | X | X | X |
8272
| regex | 130 | 0 | 0 | 0 | 0 |
83-
| float16 | 762091 | 0 | 0 | 0 | 1 |
73+
| float16 | 237 | 0 | 0 | 0 | 0 |
8474
| combinatorics | 170 | 0 | 0 | 0 | 0 |
8575
| sysinfo | 4 | 0 | 0 | 0 | 0 |
86-
| env | 105 | 0 | 0 | 0 | 0 |
87-
| rounding | 112720 | 0 | 0 | 0 | 1 |
88-
| ranges | 12123407 | 254 | 0 | 329460 | 4 |
76+
| env | 94 | 0 | 0 | 0 | 0 |
77+
| rounding | 112720 | 0 | 0 | 0 | 0 |
78+
| ranges | 12110652 | 2 | 0 | 327682 | 0 |
8979
| mod2pi | 80 | 0 | 0 | 0 | 0 |
90-
| euler | 12 | 0 | 0 | 0 | 2 |
91-
| show | X | X | X | X | X |
92-
| client | 0 | 4 | 0 | 0 | 0 |
80+
| euler | 12 | 0 | 0 | 0 | 0 |
81+
| show | 128879 | 0 | 0 | 8 | 0 |
82+
| client | 2 | 3 | 0 | 0 | 0 |
9383
| errorshow | X | X | X | X | X |
94-
| sets | 3529 | 0 | 0 | 1 | 1 |
84+
| sets | 3594 | 0 | 0 | 1 | 0 |
9585
| goto | 19 | 0 | 0 | 0 | 0 |
96-
| llvmcall | X | X | X | X | X |
9786
| llvmcall2 | 7 | 0 | 0 | 0 | 0 |
98-
| ryu | 31194 | 0 | 21 | 0 | 1 |
99-
| some | 71 | 0 | 0 | 0 | 0 |
100-
| meta | 66 | 2 | 1 | 0 | 0 |
87+
| ryu | 31215 | 0 | 0 | 0 | 0 |
88+
| some | 72 | 0 | 0 | 0 | 0 |
89+
| meta | 69 | 0 | 0 | 0 | 0 |
10190
| stacktraces | X | X | X | X | X |
102-
| docs | 235 | 1 | 0 | 0 | 2 |
91+
| docs | 237 | 1 | 0 | 0 | 0 |
10392
| misc | X | X | X | X | X |
10493
| threads | X | X | X | X | X |
10594
| stress | 0 | 0 | 0 | 0 | 0 |
106-
| binaryplatforms | 341 | 0 | 0 | 0 | 1 |
95+
| binaryplatforms | 341 | 0 | 0 | 0 | 0 |
10796
| atexit | 40 | 0 | 0 | 0 | 0 |
10897
| enums | 99 | 0 | 0 | 0 | 0 |
109-
| cmdlineargs | 242 | 0 | 0 | 3 | 0 |
110-
| int | 524693 | 0 | 0 | 0 | 1 |
98+
| cmdlineargs | 255 | 0 | 0 | 3 | 0 |
99+
| int | 524698 | 0 | 0 | 0 | 0 |
111100
| interpreter | 3 | 0 | 0 | 0 | 0 |
112101
| checked | 1239 | 0 | 0 | 0 | 0 |
113102
| bitset | 195 | 0 | 0 | 0 | 0 |
114-
| floatfuncs | 208 | 0 | 13 | 0 | 2 |
103+
| floatfuncs | 215 | 0 | 0 | 0 | 0 |
115104
| precompile | X | X | X | X | X |
116105
| boundscheck | X | X | X | X | X |
117106
| error | 31 | 0 | 0 | 0 | 0 |
118-
| cartesian | 238 | 0 | 0 | 3 | 0 |
107+
| cartesian | 343 | 0 | 0 | 3 | 0 |
119108
| osutils | 57 | 0 | 0 | 0 | 0 |
120-
| channels | X | X | X | X | X |
109+
| channels | 252 | 6 | 0 | 0 | 0 |
121110
| iostream | 50 | 0 | 0 | 0 | 0 |
122111
| secretbuffer | 27 | 0 | 0 | 0 | 0 |
123112
| specificity | X | X | X | X | X |
124113
| reinterpretarray | 232 | 0 | 0 | 0 | 0 |
125114
| syntax | X | X | X | X | X |
126115
| corelogging | 230 | 1 | 0 | 0 | 0 |
127-
| missing | 563 | 0 | 2 | 1 | 1 |
116+
| missing | 565 | 0 | 0 | 1 | 0 |
128117
| asyncmap | 304 | 0 | 0 | 0 | 0 |
129118
| smallarrayshrink | 36 | 0 | 0 | 0 | 0 |
130119
| opaque_closure | X | X | X | X | X |

src/construct.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const compiled_modules = Set{Module}()
3535

3636
const junk_framedata = FrameData[] # to allow re-use of allocated memory (this is otherwise a bottleneck)
3737
const junk_frames = Frame[]
38+
disable_recycle() = true
3839
debug_recycle() = false
3940
@noinline function _check_frame_not_in_junk(frame)
4041
@assert frame.framedata junk_framedata
@@ -43,8 +44,8 @@ end
4344

4445
@inline function recycle(frame)
4546
debug_recycle() && _check_frame_not_in_junk(frame)
46-
push!(junk_framedata, frame.framedata)
47-
push!(junk_frames, frame)
47+
disable_recycle() || push!(junk_framedata, frame.framedata)
48+
disable_recycle() || push!(junk_frames, frame)
4849
end
4950

5051
function return_from(frame::Frame)
@@ -264,14 +265,16 @@ function prepare_framedata(framecode, argvals::Vector{Any}, lenv::SimpleVector=e
264265
ng, ns = isa(ssavt, Int) ? ssavt : length(ssavt::Vector{Any}), length(src.slotflags)
265266
if length(junk_framedata) > 0
266267
olddata = pop!(junk_framedata)
267-
locals, ssavalues, sparams = olddata.locals, olddata.ssavalues, olddata.sparams
268+
locals, ssavalues, times, sparams = olddata.locals, olddata.ssavalues, olddata.times, olddata.sparams
268269
exception_frames, last_reference = olddata.exception_frames, olddata.last_reference
269270
last_exception = olddata.last_exception
270271
callargs = olddata.callargs
271272
resize!(locals, ns)
272273
fill!(locals, nothing)
273274
resize!(ssavalues, 0)
274275
resize!(ssavalues, ng)
276+
resize!(times, 0)
277+
resize!(times, ng)
275278
# for check_isdefined to work properly, we need sparams to start out unassigned
276279
resize!(sparams, 0)
277280
empty!(exception_frames)
@@ -280,6 +283,7 @@ function prepare_framedata(framecode, argvals::Vector{Any}, lenv::SimpleVector=e
280283
else
281284
locals = Vector{Union{Nothing,Some{Any}}}(nothing, ns)
282285
ssavalues = Vector{Any}(undef, ng)
286+
times = Vector{UInt64}(undef, ng)
283287
sparams = Vector{Any}(undef, 0)
284288
exception_frames = Int[]
285289
last_reference = Vector{Int}(undef, ns)
@@ -310,7 +314,7 @@ function prepare_framedata(framecode, argvals::Vector{Any}, lenv::SimpleVector=e
310314
isa(T, TypeVar) && continue # only fill concrete types
311315
sparams[i] = T
312316
end
313-
FrameData(locals, ssavalues, sparams, exception_frames, last_exception, caller_will_catch_err, last_reference, callargs)
317+
FrameData(locals, ssavalues, times, sparams, exception_frames, last_exception, caller_will_catch_err, last_reference, callargs)
314318
end
315319

316320
"""

src/types.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ Important fields:
194194
struct FrameData
195195
locals::Vector{Union{Nothing,Some{Any}}}
196196
ssavalues::Vector{Any}
197+
times::Vector{UInt64}
197198
sparams::Vector{Any}
198199
exception_frames::Vector{Int}
199200
last_exception::Base.RefValue{Any}

test/juliatests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ while i <= length(ARGS)
4545
end
4646
end
4747

48-
tests, _, exit_on_error, seed = choosetests(ARGS)
48+
tests, _, exit_on_error, seed = choosetests(["--skip", "llvmcall", "compiler", "stdlib", ARGS...])
4949

5050
function spin_up_worker()
5151
p = addprocs(1)[1]

test/utils.jl

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,24 +157,30 @@ function evaluate!(@nospecialize(recurse), frame::Frame, istoplevel::Bool=false)
157157
pc = frame.pc
158158
while true
159159
shouldbreak(frame, pc) && return BreakpointRef(frame.framecode, pc)
160-
stmt = pc_expr(frame, pc)
160+
stmt = pc_expr(frame, pc)
161+
if isassigned(frame.framedata.times, pc) && frame.framedata.times[pc] > 0
162+
recurse_pc = Compiled()
163+
else
164+
recurse_pc = recurse
165+
end
166+
time = time_ns()
161167
if isa(stmt, Expr)
162-
if stmt.head == :call && !isa(recurse, Compiled)
168+
if stmt.head == :call && !isa(recurse_pc, Compiled)
163169
try
164170
rhs = evaluate_call!(exec!, frame, stmt)
165171
lhs = SSAValue(pc)
166172
do_assignment!(frame, lhs, rhs)
167173
new_pc = pc + 1
168174
catch err
169-
new_pc = handle_err(recurse, frame, err)
175+
new_pc = handle_err(recurse_pc, frame, err)
170176
end
171-
elseif stmt.head == :(=) && isexpr(stmt.args[2], :call) && !isa(recurse, Compiled)
177+
elseif stmt.head == :(=) && isexpr(stmt.args[2], :call) && !isa(recurse_pc, Compiled)
172178
try
173179
rhs = evaluate_call!(exec!, frame, stmt.args[2])
174180
do_assignment!(frame, stmt.args[1], rhs)
175181
new_pc = pc + 1
176182
catch err
177-
new_pc = handle_err(recurse, frame, err)
183+
new_pc = handle_err(recurse_pc, frame, err)
178184
end
179185
elseif istoplevel && stmt.head == :thunk
180186
code = stmt.args[1]
@@ -183,12 +189,12 @@ function evaluate!(@nospecialize(recurse), frame::Frame, istoplevel::Bool=false)
183189
new_pc = pc + 1
184190
else
185191
newframe = Frame(moduleof(frame), code)
186-
if isa(recurse, Compiled)
187-
JuliaInterpreter.finish!(recurse, newframe, true)
192+
if isa(recurse_pc, Compiled)
193+
JuliaInterpreter.finish!(recurse_pc, newframe, true)
188194
else
189195
newframe.caller = frame
190196
frame.callee = newframe
191-
exec!(recurse, newframe, istoplevel)
197+
exec!(recurse_pc, newframe, istoplevel)
192198
frame.callee = nothing
193199
end
194200
JuliaInterpreter.recycle(newframe)
@@ -197,16 +203,21 @@ function evaluate!(@nospecialize(recurse), frame::Frame, istoplevel::Bool=false)
197203
return nothing
198204
end
199205
elseif istoplevel && stmt.head == :method && length(stmt.args) == 3
200-
step_expr!(recurse, frame, stmt, istoplevel)
206+
step_expr!(recurse_pc, frame, stmt, istoplevel)
201207
frame.pc = pc + 1
202208
return nothing
203209
else
204-
new_pc = step_expr!(recurse, frame, stmt, istoplevel)
210+
new_pc = step_expr!(recurse_pc, frame, stmt, istoplevel)
205211
end
206212
else
207-
new_pc = step_expr!(recurse, frame, stmt, istoplevel)
213+
new_pc = step_expr!(recurse_pc, frame, stmt, istoplevel)
208214
end
209215
(new_pc === nothing || isa(new_pc, BreakpointRef)) && break
216+
if !isassigned(frame.framedata.times, pc)
217+
frame.framedata.times[pc] = time_ns() - time
218+
else
219+
frame.framedata.times[pc] += time_ns() - time
220+
end
210221
pc = frame.pc = new_pc
211222
end
212223
# Handle the return
@@ -305,7 +316,7 @@ function run_test_by_eval(test, fullpath)
305316
modexs = collect(ExprSplitter(JuliaTests, ex))
306317
for (i, modex) in enumerate(modexs) # having the index can be useful for debugging
307318
local mod, ex = modex
308-
@show mod ex
319+
# @show mod ex
309320
frame = Frame(mod, ex)
310321
while true
311322
yield() # allow communication between processes

0 commit comments

Comments
 (0)