Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

perf: add cache support to evaluation in reearth/core #573

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

pyshx
Copy link
Contributor

@pyshx pyshx commented Mar 24, 2023

Overview

This PR is for improving styling performance of reearth/core.

@netlify
Copy link

netlify bot commented Mar 24, 2023

Deploy Preview for reearth-web ready!

Name Link
🔨 Latest commit d4b953f
🔍 Latest deploy log https://app.netlify.com/sites/reearth-web/deploys/6423b4990e3d1e00080de5ea
😎 Deploy Preview https://deploy-preview-573--reearth-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@pyshx pyshx requested a review from keiya01 March 25, 2023 05:20
@pyshx pyshx marked this pull request as ready for review March 25, 2023 05:20
@pyshx pyshx changed the title perf: add concurrency to evaluator and cache support perf: add cache support to evaluation in reearth/core Mar 25, 2023
@codecov
Copy link

codecov bot commented Mar 25, 2023

Codecov Report

Merging #573 (d4b953f) into main (e8050c6) will increase coverage by 0.12%.
The diff coverage is 84.73%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #573      +/-   ##
==========================================
+ Coverage   26.97%   27.10%   +0.12%     
==========================================
  Files         746      748       +2     
  Lines       87439    87626     +187     
  Branches     1883     1916      +33     
==========================================
+ Hits        23590    23750     +160     
- Misses      63758    63783      +25     
- Partials       91       93       +2     
Impacted Files Coverage Δ
src/core/mantle/evaluator/simple/index.ts 68.94% <57.14%> (-2.58%) ⬇️
src/core/mantle/evaluator/simple/utils.ts 85.71% <85.71%> (ø)
src/core/mantle/evaluator/simple/utils.test.ts 100.00% <100.00%> (ø)

}
}

export function getReferences(expression: string, feature?: any): string[] {
Copy link
Member

Choose a reason for hiding this comment

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

We have two function to parse expression. First is this function. Second is replaceVariables.
But these are very heavy task, so it will make app slower...
I think it's better to share the result of parsing with Expression class, and if we remove replaceVariables then performance will be more improved.

Copy link
Contributor Author

@pyshx pyshx Mar 26, 2023

Choose a reason for hiding this comment

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

I think it'll be hard to separate out alot the repetitive logic and avoid iterating over the string again in replaceVariables now that i've removed JP related evaluations.

return new ConditionalExpression(styleExpression, feature, layer.defines).evaluate();
const cacheKey = JSON.stringify([
styleExpression,
getCacheableProperties(styleExpression, feature?.properties),
Copy link
Member

@keiya01 keiya01 Mar 26, 2023

Choose a reason for hiding this comment

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

We don't have to instantiate Expression no more, but we become to need to parse expression every time...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hopefully this will be less heavy with the cache for getReferences in place.

Copy link
Member

@keiya01 keiya01 left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you.

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

Successfully merging this pull request may close these issues.

2 participants