Avatar for the gadget-inc user
gadget-inc
mobx-quick-tree
BlogDocsChangelog

`defineProperty` based property memoization

#92Closed
Comparing
faster-get-5
(
58da4e6
) with
main
(
f183291
)
CodSpeed Performance Gauge
-28%
Improvements
4
Regressions
1
Untouched
3
New
0
Dropped
0
Ignored
4

Benchmarks

Failed

accessing unmemoized null property of a class modelRegression
bench/property-access-model-class.ts::accessing unmemoized null property of a class model
CodSpeed Performance Gauge
-28%
17.5 µs
24.1 µs

Improved

accessing unmemoized getter properties of a class model
bench/property-access-model-class.ts::accessing unmemoized getter properties of a class model
CodSpeed Performance Gauge
+48%
66.6 µs
44.9 µs
accessing memoized getter properties of a class model
bench/property-access-model-class.ts::accessing memoized getter properties of a class model
CodSpeed Performance Gauge
+44%
15.2 µs
10.5 µs
accessing memoized null property of a class model
bench/property-access-model-class.ts::accessing memoized null property of a class model
CodSpeed Performance Gauge
+29%
14.4 µs
11.2 µs
instantiating a large root
bench/all.ts::instantiating a large root
CodSpeed Performance Gauge
+15%
4 ms
3.5 ms

Passed

instantiating a small root
bench/all.ts::instantiating a small root
CodSpeed Performance Gauge
+3%
46.8 µs
45.5 µs
instantiating a diverse root
bench/all.ts::instantiating a diverse root
CodSpeed Performance Gauge
+2%
56.4 µs
55.1 µs
instantiating a large union
bench/all.ts::instantiating a large union
CodSpeed Performance Gauge
-8%
86.1 µs
93.8 µs

Ignored

instantiating a diverse root (mobx-state-tree)Ignored
bench/all.ts::instantiating a diverse root (mobx-state-tree)
CodSpeed Performance Gauge
-4%
2.2 ms
2.3 ms
instantiating a large root (mobx-state-tree)Ignored
bench/all.ts::instantiating a large root (mobx-state-tree)
CodSpeed Performance Gauge
+5%
270.7 ms
258.3 ms
instantiating a large union (mobx-state-tree)Ignored
bench/all.ts::instantiating a large union (mobx-state-tree)
CodSpeed Performance Gauge
-3%
3 ms
3.1 ms
instantiating a small root (mobx-state-tree)Ignored
bench/all.ts::instantiating a small root (mobx-state-tree)
CodSpeed Performance Gauge
-7%
1.3 ms
1.4 ms

Commits

Click on a commit to change the comparison range
Base
main
f183291
-40%
Eval a fast property memoizer to microoptimize property access for cached views This implements a better performing getter function for readonly instances. Before this, we used the same definition of the getter function for all views, which ended up megamorphic, because it accessed a very wide variety of properties for every instance! Instead, this evals a monomorphic getter for each one. I also changed the object that stores the memos to have a fixed shape from birth by evaling it out as well. I also changed us to use one object to store all the memoized values, instead of two. We were previously using two in order to implement memoization of undefined and null correctly, but with the new strategy to initialize an object with slots for every memo from the start, we can populate it with a `$notYetMemoized` symbol that indicates if we have memoized or not.
cff0d11
1 year ago
by airhorns
+12%
Eval a fast property memoizer to microoptimize property access for cached views This implements a better performing getter function for readonly instances. Before this, we used the same definition of the getter function for all views, which ended up megamorphic, because it accessed a very wide variety of properties for every instance! Instead, this evals a monomorphic getter for each one. I also changed the object that stores the memos to have a fixed shape from birth by evaling it out as well. I also changed us to use one object to store all the memoized values, instead of two. We were previously using two in order to implement memoization of undefined and null correctly, but with the new strategy to initialize an object with slots for every memo from the start, we can populate it with a `$notYetMemoized` symbol that indicates if we have memoized or not.
58da4e6
1 year ago
by airhorns
© 2025 CodSpeed Technology
Home Terms Privacy Docs