Repository navigation
BHoM_Engine: Improve performance of (Try)RunExtensionMethod - #3658
Open
IsakNaslundBh wants to merge 6 commits into
Open
IsakNaslundBh wants to merge 6 commits into
IsakNaslundBh wants to merge 6 commits into
Conversation
Make use of custom keys to improve method access and runtime Get rid of locks not required with ConcurrentDictionaries Store hits and misses (avoid re-running for nulls) Ensure null-methods are cleared when a new assembly is loaded
Also here, gets rid of locks not required for COncurrentDictionaries
Previously was doing that, but in a two-step process. This changes it to make use of the Try method. This method was changed before the TryRun pattern existed.
Rely on the previously used method.ToFunc()
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issues addressed by this PR
Closes #3654
Improve performance of (Try)RunExtensionMethod
This PR does two main updates:
The performance gain from this will ofc vary both by method and runtime.
For methods with extremly low execution time (like the named Geometry method for a Node) this will mean a up to 7 times improvement in execution time. For slower methods (like Transform for Node) we are more talking about shaving off 20-30% of the runtime (compared to the 80-90% for the really small methods).
For larger methods this wont really matter at all to a large extent.
The part that can make this critical is for when running a method is called a multitude of times, like inside loops or similar, where the previous overhead was slowing down the operation, and leading to situations where the bottlneck was not actually executing the method, but string-concatination and hash computation of named concatenated strings.
This should anyhow give a large to minor performance boost for all extension method runners, without degrading any of the performance.
To note is that I also evaluated other slightly more complex options, including various generic
ExtentionMethodRunnerswith precompiled switches on types etc. THose could in theory squeeze out a tiny fraction mroe of performance, but the gains there started to get to small for me to think that overhead in complication was worth implementing. Can revisit those if we feel there are cases that show this being an issue.Test files
Will link to various workflows that makes heavy use of this, but as a simple test, All of our visible geometry in GH is going through this method.
Changelog
Additional comments