Skip to content

more cache hits for getMaxTickWidth#2687

Open
panthony wants to merge 1 commit intoc3js:masterfrom
cogniteev:patch/12-cache-sizes
Open

more cache hits for getMaxTickWidth#2687
panthony wants to merge 1 commit intoc3js:masterfrom
cogniteev:patch/12-cache-sizes

Conversation

@panthony
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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.

@panthony panthony force-pushed the patch/12-cache-sizes branch from b5183d6 to 0325fb6 Compare August 21, 2019 07:19
Comment thread src/axis.js
});

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

Choose a reason for hiding this comment

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

nice early return 👍

Comment thread src/core.js
durationForAxis = withTransitionForAxis ? duration : 0;

// reset caches when we are re-drawing the chart
$$.resetCache();
Copy link
Copy Markdown
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
Copy Markdown
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....)

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.04%. Comparing base (4cb80e7) to head (0325fb6).
⚠️ Report is 125 commits behind head on master.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            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              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

4 participants