Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Comments

Continue improving the LU section CRUD's performance#905

Merged
Danieladu merged 17 commits intomasterfrom
hond/luparser-perf
Jul 20, 2020
Merged

Continue improving the LU section CRUD's performance#905
Danieladu merged 17 commits intomasterfrom
hond/luparser-perf

Conversation

@Danieladu
Copy link
Contributor

@Danieladu Danieladu commented Jul 20, 2020

Fixed: #906
Continue improving the LU section CRUD's performance.

What the previous PR #901 has done:

  • Replace property parseTree with range in section
  • Only parse corresponding lu content to avoid the whole file parsing
  • Use cloneDeep and cloneDeepWith to keep the input resource Immutable
  • Adjust section and error range

The effect of the previous PR

  • Avoid the whole file parsing to improve performance.

What this PR did:

  • Remove unused code
  • Replace cloneDeep and cloneDeepWith with JSON.parse(JSON.stringify(luresource)); to improve the clone performance.

The effect of this PR

  • Reduce the clone time of Section CRUD operator.
    Use cloneDeep and cloneDeepWith : 50ms
    Just use JSON serialization and Deserialization: < 1ms

What next would do:

  • Adjust grammar file of LU parser to improve the parsing performance.

The effect of the next PR

  • Improve the performance of parsing a single LU file

@Danieladu Danieladu requested a review from munozemilio as a code owner July 20, 2020 02:00
@Danieladu Danieladu changed the title Continue improve the LU section CRUD's performance Continue improving the LU section CRUD's performance Jul 20, 2020
@codecov-commenter
Copy link

Codecov Report

Merging #905 into master will increase coverage by 0.11%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #905      +/-   ##
==========================================
+ Coverage   57.15%   57.27%   +0.11%     
==========================================
  Files         220      219       -1     
  Lines       16159    16195      +36     
  Branches     2220     2222       +2     
==========================================
+ Hits         9236     9275      +39     
+ Misses       6368     6365       -3     
  Partials      555      555              
Impacted Files Coverage Δ
packages/lu/src/parser/lufile/sectionOperator.js 88.65% <100.00%> (+1.81%) ⬆️
packages/lg/src/commands/lg/index.ts 66.66% <0.00%> (-16.67%) ⬇️
packages/config/src/commands/config/set.ts 100.00% <0.00%> (ø)
packages/config/src/utils/configfilehandler.ts 100.00% <0.00%> (ø)
packages/plugins/src/commands/plugins/index.ts 100.00% <0.00%> (ø)
packages/config/src/commands/config/set/luis.ts 100.00% <0.00%> (ø)
packages/config/src/commands/config/show/luis.ts 100.00% <0.00%> (ø)
...ackages/config/src/commands/config/set/qnamaker.ts 100.00% <0.00%> (ø)
...ckages/config/src/commands/config/set/telemetry.ts 100.00% <0.00%> (ø)
...ckages/config/src/commands/config/show/qnamaker.ts 100.00% <0.00%> (ø)
... and 6 more

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 7816875...17eedfd. Read the comment docs.

@boydc2014
Copy link
Contributor

@zhixzhan can you help check this

@boydc2014
Copy link
Contributor

@Danieladu also, to avoid confusing in PR review, please list more context, what previous you did to improve perf, and what's this one for, and any other further plans to improve performance.

@zhixzhan
Copy link

@zhixzhan can you help check this

Sure, my another question is

const newResource = new sectionOperator(resource).updateSection(targetSection.Id, targetSectionContent);

this methods modify on parameter resource, but also return newResource that could probably make little confuse, and even cause error when parameter is defined as immutable.

I suggest do not modify parameter resource, which make API implementation is Pure Function has no side effect.

@feich-ms feich-ms self-requested a review July 20, 2020 02:54
@Danieladu
Copy link
Contributor Author

@zhixzhan can you help check this

Sure, my another question is

const newResource = new sectionOperator(resource).updateSection(targetSection.Id, targetSectionContent);

this methods modify on parameter resource, but also return newResource that could probably make little confuse, and even cause error when parameter is defined as immutable.

I suggest do not modify parameter resource, which make API implementation is Pure Function has no side effect.

Yes, the input luresource would not be modified. But each CRUD operator is Iterative.
For example:

var luresource = xxx;
const operator = new SectionOperator(luresource);
const newresource1 = operator.updateSection(yyy);
const newresource2 = operator.updateSection(zzz);

The operator: const newSection2 = operator.updateSection(zzz); is based on the resource newresource1

@Danieladu Danieladu merged commit 88a2a42 into master Jul 20, 2020
@Danieladu Danieladu deleted the hond/luparser-perf branch July 20, 2020 03:38
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.

Use simple json.parse and json.stringify instead of cloneDeep in SectionOperator constructor

5 participants