DynamoModel startup time improvements#16236
Open
dimven-adsk wants to merge 2 commits intoDynamoDS:masterfrom
Open
DynamoModel startup time improvements#16236dimven-adsk wants to merge 2 commits intoDynamoDS:masterfrom
dimven-adsk wants to merge 2 commits intoDynamoDS:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR improves DynamoModel startup performance by replacing expensive LINQ and string concatenations with cached loops and interpolations, and introduces caching for assembly reflection calls.
- Add a null guard on
SearchModeland replace LINQ with a manual loop in the custom node manager hot path - Simplify XML documentation lookup with early returns and string interpolation
- Introduce an assembly load context cache in
StartupUtilsand update ignore list entries
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/DynamoCore/Models/DynamoModel.cs | Guard against null SearchModel and avoid LINQ in hot path for custom node lookups |
| src/DynamoCore/Library/XmlDocumentationExtensions.cs | Consolidate null/empty checks and use string interpolation for fully qualified member names |
| src/DynamoCore/Library/LibraryCustomization.cs | Swap ContainsKey + indexer for TryGetValue |
| src/DynamoCore/Library/FunctionDescriptor.cs | Replace multi-step filtering and concatenations with OfType and interpolated strings |
| src/DynamoApplications/StartupUtils.cs | Add LoadedAssembliesCache, update ignore list entries, and refactor assembly mismatch logic |
Comments suppressed due to low confidence (4)
src/DynamoCore/Models/DynamoModel.cs:1523
- [nitpick] The null-conditional operator on
cnSearch?.Pathis redundant sinceentry is not CustomNodeSearchElement cnSearchalready ensurescnSearchis non-null. You can simplify tocnSearch.Path.
if (entry is not CustomNodeSearchElement cnSearch || string.IsNullOrWhiteSpace(cnSearch?.Path) || ...)
src/DynamoApplications/StartupUtils.cs:442
- [nitpick] Private static field names should follow camelCase naming conventions (e.g.,
loadedAssembliesCache) to match the project's style.
private static Dictionary<string, Dictionary<string, (Assembly, AssemblyName)>> LoadedAssembliesCache = new Dictionary<string, Dictionary<string, (Assembly, AssemblyName)>>();
src/DynamoApplications/StartupUtils.cs:463
- The new caching logic for
LoadedAssembliesCacheshould be covered by unit tests to verify cache population, retrieval, and update behavior under differentAssemblyLoadContextscenarios.
if (!LoadedAssembliesCache.TryGetValue(loadContext.Name, out var loadedAssemblies))
src/DynamoApplications/StartupUtils.cs:429
- [nitpick] Consider using the C# alias
string[]instead ofString[]for built-in types to align with common style guidelines.
private static readonly String[] assemblyNamesToIgnore = { "Newtonsoft.Json", "RevitAPI", "RevitAPIUI" };
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.
Purpose
This PR focuses on the DynamoModel startup performance, specifically when running under Revit and with the 10 most popular packages installed. These modified code paths are not as critical under Dynamo core because they are not visited as often.
Snapshot of the current performance:
Proposed changes:
These changes do not change the underlying logic but can improve the model startup performance by 4~5%.
Declarations
Check these if you believe they are true
*.resxfilesRelease Notes
(FILL ME IN) Brief description of the fix / enhancement. Use N/A to indicate that the changes in this pull request do not apply to Release Notes. Mandatory section
Reviewers
(FILL ME IN) Reviewer 1 (If possible, assign the Reviewer for the PR)
(FILL ME IN, optional) Any additional notes to reviewers or testers.
FYIs
(FILL ME IN, Optional) Names of anyone else you wish to be notified of