Improve perf of _computeBarPixelThickness by memoizing gets to it, reducing intermediate wasted computes (intermediate computes are computations that are called before renderImmediately).
Implementing memoization in Plottable is complicated by mutable scales and datasets. To resolve this we write a recursive Signature interface that holds an immutable snapshot of whatever state the scale/data was in at the time. Then on memoized function invocation we sign the new inputs and compare the signatures to decide if we should recompute.
Unfortunately signing and comparison is itself a performance hit; in tests they took ~0.3ms per get (which, for 3k bars, is 900ms of overhead), which is unacceptable. To get around this, we notice that almost all of these gets happen inside Plot.renderImmediately (aka getting the thickness of the bar to actually render the bar). Thus we introduce the "doLocked" method that momentarily bypasses sign/comparison logic and simply returns the cached value.
This paves the way for more perf improvements as we refactor other code to using the sign and memoize API - e.g. #2495, #3117, #2949
Improve perf of _computeBarPixelThickness by memoizing gets to it, reducing intermediate wasted computes (intermediate computes are computations that are called before renderImmediately).
Implementing memoization in Plottable is complicated by mutable scales and datasets. To resolve this we write a recursive Signature interface that holds an immutable snapshot of whatever state the scale/data was in at the time. Then on memoized function invocation we sign the new inputs and compare the signatures to decide if we should recompute.
Unfortunately signing and comparison is itself a performance hit; in tests they took ~0.3ms per get (which, for 3k bars, is 900ms of overhead), which is unacceptable. To get around this, we notice that almost all of these gets happen inside Plot.renderImmediately (aka getting the thickness of the bar to actually render the bar). Thus we introduce the "doLocked" method that momentarily bypasses sign/comparison logic and simply returns the cached value.
This paves the way for more perf improvements as we refactor other code to using the sign and memoize API - e.g. #2495, #3117, #2949
Starts tackling #3302