Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more cache hits for getMaxTickWidth #2687

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

panthony
Copy link
Contributor

@panthony panthony commented Aug 19, 2019

This PR:

  • removes withoutRecompute and always return cached version if exists
  • reuse addToCache and getFromCache instead of custom property
  • add call to resetCache when redraw is called.

This way we have more cache hits and the cache is dropped each time we want to redraw the chart (thinking of resize etc.) which should be, hopefully, sufficient.

@codecov-io
Copy link

Codecov Report

Merging #2687 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2687      +/-   ##
==========================================
+ Coverage   81.02%   81.03%   +0.01%     
==========================================
  Files          59       59              
  Lines        4633     4636       +3     
==========================================
+ Hits         3754     3757       +3     
  Misses        879      879
Impacted Files Coverage Δ
src/core.js 90.74% <100%> (ø) ⬆️
src/size.js 93.75% <100%> (ø) ⬆️
src/axis.js 97.6% <100%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4cb80e7...b5183d6. Read the comment docs.

@codecov-io
Copy link

codecov-io commented Aug 19, 2019

Codecov Report

Merging #2687 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2687      +/-   ##
==========================================
+ Coverage   81.02%   81.04%   +0.01%     
==========================================
  Files          59       59              
  Lines        4633     4637       +4     
==========================================
+ Hits         3754     3758       +4     
  Misses        879      879
Impacted Files Coverage Δ
src/core.js 90.76% <100%> (+0.01%) ⬆️
src/size.js 93.75% <100%> (ø) ⬆️
src/axis.js 97.6% <100%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4163be5...0325fb6. Read the comment docs.

});

// bypass if SVG not rendered yet
if (!$$.svg) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice early return 👍

@@ -533,6 +527,9 @@ ChartInternal.prototype.redraw = function(options, transitions) {
durationForExit = withTransitionForExit ? duration : 0;
durationForAxis = withTransitionForAxis ? duration : 0;

// reset caches when we are re-drawing the chart
$$.resetCache();
Copy link
Member

@kt3k kt3k Aug 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this resetting of cache might be inconvenient for some future use cases. How about resetting only some groups of caches by the key?

$$.resetCache('MaxTickWidth') // => reset cache which has the key /^\$MaxTickWidth/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I though about this when I tried to use this method for legendItemTextBox too where reseting this cache here would be unnecessary.

I think there will be some kind of tradeoff between ease of use (aka: Forget to reset a cache here & there) & performance.

I think there are 2 families of cached values:

  • The ones that are impacted by an update of data (added, removed targets, etc.)
  • The ones that are impacted by an update of sizing (resize, update of CSS....)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants