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

Optimize Instructions cache #120

Merged
merged 5 commits into from
Apr 11, 2019

Conversation

shargon
Copy link
Member

@shargon shargon commented Apr 10, 2019

Use Script class for caching the instructions instead of ExecutionContext

@shargon shargon requested a review from erikzhang April 10, 2019 14:52
@codecov-io
Copy link

Codecov Report

Merging #120 into master will decrease coverage by 0.34%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #120      +/-   ##
==========================================
- Coverage   80.66%   80.32%   -0.35%     
==========================================
  Files          45       45              
  Lines        4578     4529      -49     
==========================================
- Hits         3693     3638      -55     
- Misses        885      891       +6
Impacted Files Coverage Δ
src/neo-vm/ExecutionContext.cs 87.5% <100%> (-12.5%) ⬇️
src/neo-vm/Script.cs 95.83% <100%> (-4.17%) ⬇️

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 07aa32b...538c900. Read the comment docs.

@codecov-io
Copy link

codecov-io commented Apr 10, 2019

Codecov Report

Merging #120 into master will decrease coverage by 0.33%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #120      +/-   ##
==========================================
- Coverage   80.89%   80.56%   -0.34%     
==========================================
  Files          45       45              
  Lines        4633     4584      -49     
==========================================
- Hits         3748     3693      -55     
- Misses        885      891       +6
Impacted Files Coverage Δ
src/neo-vm/ExecutionContext.cs 87.5% <100%> (-12.5%) ⬇️
src/neo-vm/Script.cs 95.83% <100%> (-4.17%) ⬇️

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 cf869a7...40cbb0a. Read the comment docs.

Copy link
Contributor

@igormcoelho igormcoelho left a comment

Choose a reason for hiding this comment

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

What changed? The aggressive inline?

@shargon
Copy link
Member Author

shargon commented Apr 10, 2019

Previously we cached the instructions inside ExecutionContext, so if you made a CALL inside other call, you will create two ExecutionContexts with different caches, after this change, the script have this cache, so every ExecutionContext who comes from one Script, share his cache.

igormcoelho
igormcoelho previously approved these changes Apr 10, 2019
Copy link
Contributor

@igormcoelho igormcoelho left a comment

Choose a reason for hiding this comment

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

Looks fine to me!

@igormcoelho
Copy link
Contributor

As soon as this is merged, we can improve #121 with the final tests missing here.

/// <summary>
/// Number of items to be returned
/// </summary>
internal int RVCount { get; }
public int RVCount { get; }
Copy link
Member

Choose a reason for hiding this comment

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

Why change this to public?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because is read only, and maybe we need it for debuggers or something like that

@@ -8,6 +9,7 @@ public class Script

private readonly byte[] _value;
private readonly ICrypto _crypto;
private readonly IDictionary<int, Instruction> _instructions = new Dictionary<int, Instruction>();
Copy link
Member

Choose a reason for hiding this comment

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

I think it's not necessary to use interface for a private field.

@shargon shargon merged commit f0f8090 into neo-project:master Apr 11, 2019
@shargon shargon deleted the optimize-script-cache branch April 11, 2019 09:07
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.

4 participants