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
Ignored
4

Benchmarks

Failed

accessing unmemoized null property of a class model
bench/property-access-model-class.ts
Regression
CodSpeed Performance Gauge
-28%
17.5 µs24.1 µs

Improved

accessing unmemoized getter properties of a class model
bench/property-access-model-class.ts
CodSpeed Performance Gauge
+48%
66.6 µs44.9 µs
accessing memoized getter properties of a class model
bench/property-access-model-class.ts
CodSpeed Performance Gauge
+44%
15.2 µs10.5 µs
accessing memoized null property of a class model
bench/property-access-model-class.ts
CodSpeed Performance Gauge
+29%
14.4 µs11.2 µs
instantiating a large root
bench/all.ts
CodSpeed Performance Gauge
+15%
4 ms3.5 ms

Passed

instantiating a small root
bench/all.ts
CodSpeed Performance Gauge
+3%
46.8 µs45.5 µs
instantiating a diverse root
bench/all.ts
CodSpeed Performance Gauge
+2%
56.4 µs55.1 µs
instantiating a large union
bench/all.ts
CodSpeed Performance Gauge
-8%
86.1 µs93.8 µs

Ignored

instantiating a small root (mobx-state-tree)
bench/all.ts
Ignored
CodSpeed Performance Gauge
-7%
1.3 ms1.4 ms
instantiating a large root (mobx-state-tree)
bench/all.ts
Ignored
CodSpeed Performance Gauge
+5%
270.7 ms258.3 ms
instantiating a diverse root (mobx-state-tree)
bench/all.ts
Ignored
CodSpeed Performance Gauge
-4%
2.2 ms2.3 ms
instantiating a large union (mobx-state-tree)
bench/all.ts
Ignored
CodSpeed Performance Gauge
-3%
3 ms3.1 ms

Commits

Click on a commit to change the comparison range
Base
main
f183291
-40.13%
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
2 years ago
by airhorns
+12.46%
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
2 years ago
by airhorns
© 2025 CodSpeed Technology
Home Terms Privacy Docs