BlogDocs

`defineProperty` based property memoization(#92)

Closed
Merging
faster-get-5
(
58da4e6
) into
main
(
f183291
)
-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
-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
+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
+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
+29%
14.4 µs
11.2 µs
instantiating a large root
bench/all.ts::instantiating a large root
+15%
4 ms
3.5 ms

Passed

instantiating a small root
bench/all.ts::instantiating a small root
+3%
46.8 µs
45.5 µs
instantiating a diverse root
bench/all.ts::instantiating a diverse root
+2%
56.4 µs
55.1 µs
instantiating a large union
bench/all.ts::instantiating a large union
-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)
-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)
+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)
-3%
3 ms
3.1 ms
instantiating a small root (mobx-state-tree)Ignored
bench/all.ts::instantiating a small root (mobx-state-tree)
-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
7 months 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
7 months ago
by airhorns
ResourcesHomePricingDocsBlogGitHubChangelog