-
Notifications
You must be signed in to change notification settings - Fork 665
Perf and Memory optimization for Graph execution #16295
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
Open
saintentropy
wants to merge
16
commits into
DynamoDS:master
Choose a base branch
from
saintentropy:HotPathOptimization
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+224
−55
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f7eaebc
Clean up algorithm for hot path... Remove linq in DEP_Handler
saintentropy e763925
Combine get and update with a single call in PopTo
saintentropy 45ca5f4
Improve DSObject allocation for pointer in Marshaling
saintentropy e0f3e46
Cache last symbol lookup (PopTo optimization) stays in scope with Ex…
saintentropy 9218369
Cache interpretor object for lifetime of JIL function endpoint
saintentropy a1867af
reuse parameters array & referencePrameter list, cache marshaller & p…
saintentropy 98f38f6
Optimize check methods in CLR marshaller
saintentropy acef308
Use spans to avoid extra allocation and preallocated list sizes in Re…
saintentropy c5922d7
Improve Data access speed in MirrorData for tesselation and other loo…
saintentropy 42dccdc
pre allocate initial heapElement list size
saintentropy 58e08f3
Fix test failures
saintentropy c565687
Fix test failures in FunctionPointer
saintentropy 222feab
Fix recursive calls with interpreter
saintentropy 3d230f3
Merge branch 'master' into HotPathOptimization
saintentropy f799925
Merge branch 'master' into HotPathOptimization
saintentropy 0ca6b45
Merge branch 'master' into HotPathOptimization
saintentropy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,6 +111,17 @@ public Executive(RuntimeCore runtimeCore, bool isFep = false) | |
| deferedGraphNodes = new List<AssociativeGraph.GraphNode>(); | ||
| } | ||
|
|
||
| public void Reset(bool isFep = false) | ||
| { | ||
| pc = Constants.kInvalidIndex; | ||
| executingBlock = Constants.kInvalidIndex; | ||
| RX = StackValue.BuildInvalid(); | ||
| TX = StackValue.BuildInvalid(); | ||
| fepRun = isFep; | ||
| terminate = false; | ||
| graphNodesInProgramScope = null; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Cache the graphnodes in scope | ||
| /// </summary> | ||
|
|
@@ -2308,15 +2319,35 @@ private void Execute(int exeblock, int entry, Language language = Language.NotSp | |
| } | ||
| } | ||
|
|
||
| private int cacheBlockID = -1; | ||
| private int cacheClassIndex = -1; | ||
| private int cachesymbolIndex = -1; | ||
| private SymbolNode cachedSymbol = null; | ||
|
|
||
| protected SymbolNode GetSymbolNode(int blockId, int classIndex, int symbolIndex) | ||
| { | ||
| if (blockId == cacheBlockID && classIndex == cacheClassIndex && symbolIndex == cachesymbolIndex && cachedSymbol != null) | ||
| { | ||
| return cachedSymbol; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How much is caching really going to help here? After all you're simply avoiding array/list indexing ( |
||
| } | ||
|
|
||
| if (Constants.kGlobalScope == classIndex) | ||
| { | ||
| return exe.runtimeSymbols[blockId].symbolList[symbolIndex]; | ||
| var symbol = exe.runtimeSymbols[blockId].symbolList[symbolIndex]; | ||
| cacheBlockID = blockId; | ||
| cacheClassIndex = classIndex; | ||
| cachesymbolIndex = symbolIndex; | ||
| cachedSymbol = symbol; | ||
| return symbol; | ||
| } | ||
| else | ||
| { | ||
| return exe.classTable.ClassNodes[classIndex].Symbols.symbolList[symbolIndex]; | ||
| var symbol = exe.classTable.ClassNodes[classIndex].Symbols.symbolList[symbolIndex]; | ||
| cacheBlockID = blockId; | ||
| cacheClassIndex = classIndex; | ||
| cachesymbolIndex = symbolIndex; | ||
| cachedSymbol = symbol; | ||
| return symbol; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -2438,10 +2469,11 @@ protected StackValue PopTo(int blockId, StackValue op1, StackValue op2, StackVal | |
| case AddressType.MemVarIndex: | ||
|
|
||
| SymbolNode symbol = GetSymbolNode(blockId, op2.ClassIndex, op1.SymbolIndex); | ||
| opPrev = rmem.GetSymbolValue(symbol); | ||
| rmem.SetSymbolValue(symbol, opVal); | ||
| exe.UpdatedSymbols.Add(symbol); | ||
| opPrev = rmem.SetSymbolValueAndGetPreviousValue(symbol, opVal); | ||
|
|
||
|
|
||
| exe.UpdatedSymbols.Add(symbol); | ||
| #if DEBUG | ||
| if (IsDebugRun()) | ||
| { | ||
| logWatchWindow(blockId, op1.SymbolIndex); | ||
|
|
@@ -2452,23 +2484,25 @@ protected StackValue PopTo(int blockId, StackValue op1, StackValue op2, StackVal | |
| { | ||
| logWatchWindow(blockId, op1.SymbolIndex); | ||
| } | ||
|
|
||
| #endif | ||
| RecordExecutedGraphNode(); | ||
| break; | ||
|
|
||
| case AddressType.StaticMemVarIndex: | ||
| var staticMember = GetSymbolNode(blockId, Constants.kGlobalScope, op1.StaticVariableIndex); | ||
| opPrev = rmem.GetSymbolValue(staticMember); | ||
| rmem.SetSymbolValue(staticMember, opVal); | ||
| exe.UpdatedSymbols.Add(staticMember); | ||
| opPrev = rmem.SetSymbolValueAndGetPreviousValue(staticMember, opVal); | ||
|
|
||
|
|
||
| exe.UpdatedSymbols.Add(staticMember); | ||
| #if DEBUG | ||
| if (IsDebugRun()) | ||
| { | ||
| logWatchWindow(blockId, op1.StaticVariableIndex); | ||
| System.Console.ReadLine(); | ||
| } | ||
|
|
||
| logWatchWindow(blockId, op1.StaticVariableIndex); | ||
| #endif | ||
| break; | ||
| case AddressType.Register: | ||
| { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing
updateNodeRefList[0].nodeList[0]without checking for an empty list can throwIndexOutOfRangeException. Validate both lists before indexing or revert to a safe lookup.