@@ -18,6 +18,149 @@ are stored as `SymbolicUtils.Const` variants. Mutation such as `guesses(sys)[x]
1818possible, and values are automatically converted. However, obtaining the value back requires
1919usage of ` SymbolicUtils.unwrap_const ` or ` Symbolics.value ` .
2020
21+ Following is a before/after comparison of the TTFX for the most common operations in ModelingToolkit.jl.
22+ Further improvements are ongoing. Note that the timings do depend on many factors such as the exact system
23+ used, types passed to constructor functions, other packages currently loaded in the session, presence of
24+ array variables/equations, whether index reduction is required, and the behavior of various passes in
25+ ` mtkcompile ` . However, the numbers are good representations of the kinds of performance improvements
26+ that are possible due to the new infrastructure. There will continue to be improvements as this gets
27+ more extensive testing and we are better able to identify bottlenecks in compilation.
28+
29+ ### ` System ` constructor
30+
31+ The time to call ` System ` , not including the time taken for ` @variables ` or building the equations.
32+
33+ Before:
34+
35+ ```
36+ 0.243758 seconds (563.80 k allocations: 30.613 MiB, 99.48% compilation time: 3% of which was recompilation)
37+ elapsed time (ns): 2.43757958e8
38+ gc time (ns): 0
39+ bytes allocated: 32099616
40+ pool allocs: 563137
41+ non-pool GC allocs: 16
42+ malloc() calls: 651
43+ free() calls: 0
44+ minor collections: 0
45+ full collections: 0
46+ ```
47+
48+ After:
49+
50+ ```
51+ 0.000670 seconds (217 allocations: 10.641 KiB)
52+ elapsed time (ns): 669875.0
53+ gc time (ns): 0
54+ bytes allocated: 10896
55+ pool allocs: 217
56+ non-pool GC allocs: 0
57+ minor collections: 0
58+ full collections: 0
59+ ```
60+
61+ ### ` complete `
62+
63+ Before:
64+
65+ ```
66+ 1.795140 seconds (9.76 M allocations: 506.143 MiB, 2.67% gc time, 99.75% compilation time: 71% of which was recompilation)
67+ elapsed time (ns): 1.795140083e9
68+ gc time (ns): 47998414
69+ bytes allocated: 530729216
70+ pool allocs: 9747214
71+ non-pool GC allocs: 111
72+ malloc() calls: 10566
73+ free() calls: 8069
74+ minor collections: 5
75+ full collections: 1
76+ ```
77+
78+ After:
79+
80+ ```
81+ 0.001191 seconds (1.08 k allocations: 2.554 MiB)
82+ elapsed time (ns): 1.190625e6
83+ gc time (ns): 0
84+ bytes allocated: 2678088
85+ pool allocs: 1077
86+ non-pool GC allocs: 0
87+ malloc() calls: 3
88+ free() calls: 0
89+ minor collections: 0
90+ full collections: 0
91+ ```
92+
93+ ### ` TearingState ` constructor
94+
95+ ` TearingState ` is an intermediary step in ` mtkcompile ` . It is significant enough for the impact
96+ to be worth measuring separately.
97+
98+ Before:
99+
100+ ```
101+ 0.374312 seconds (527.01 k allocations: 32.318 MiB, 24.13% gc time, 99.60% compilation time: 85% of which was recompilation)
102+ elapsed time (ns): 3.74312e8
103+ gc time (ns): 90318708
104+ bytes allocated: 33888248
105+ pool allocs: 526440
106+ non-pool GC allocs: 11
107+ malloc() calls: 555
108+ free() calls: 2923
109+ minor collections: 1
110+ full collections: 0
111+ ```
112+
113+ After:
114+
115+ ```
116+ 0.002062 seconds (1.07 k allocations: 8.546 MiB, 50.24% compilation time)
117+ elapsed time (ns): 2.0618339999999998e6
118+ gc time (ns): 0
119+ bytes allocated: 8961560
120+ pool allocs: 1064
121+ non-pool GC allocs: 0
122+ malloc() calls: 6
123+ free() calls: 0
124+ minor collections: 0
125+ full collections: 0
126+ ```
127+
128+ ### ` mtkcompile `
129+
130+ This measures the time taken by the first call to ` mtkcompile ` . This is run after the ` TearingState `
131+ benchmark, and hence the compile time from that aspect of the process is not included (runtime is
132+ included).
133+
134+ Before:
135+
136+ ```
137+ 1.772756 seconds (3.81 M allocations: 206.068 MiB, 0.63% gc time, 99.71% compilation time: 71% of which was recompilation)
138+ elapsed time (ns): 1.772755875e9
139+ gc time (ns): 11162292
140+ bytes allocated: 216077752
141+ pool allocs: 3808615
142+ non-pool GC allocs: 61
143+ malloc() calls: 4877
144+ free() calls: 4844
145+ minor collections: 2
146+ full collections: 0
147+ ```
148+
149+ After:
150+
151+ ```
152+ 0.018629 seconds (20.74 k allocations: 932.062 KiB, 89.89% compilation time)
153+ elapsed time (ns): 1.8628542e7
154+ gc time (ns): 0
155+ bytes allocated: 954432
156+ pool allocs: 20727
157+ non-pool GC allocs: 0
158+ malloc() calls: 13
159+ free() calls: 0
160+ minor collections: 0
161+ full collections: 0
162+ ```
163+
21164## Semantic separation of discretes
22165
23166ModelingToolkit has long overloaded the meaning of ` @parameters ` to the point that it means
0 commit comments