Skip to content
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

Preload all extension types from include workflows #1890

Merged
merged 7 commits into from
Jul 10, 2024

Conversation

glopesdev
Copy link
Member

@glopesdev glopesdev commented Jul 8, 2024

Include workflows are loaded lazily and on-demand during the workflow build step, which means extension type discovery is performed in step-fashion for a newly loaded workflow. This gradual type discovery has dramatic implications in performance as documented in #1680, and this was having a visible impact on editor loading times, especially for complex applications with large numbers of include workflows.

This PR aims to improve the performance by preloading all extension types from included workflows ahead of time. The serialization of workflow properties was also optimized to minimize the number of required serializer instances.

The preloading optimization is disabled during builds to avoid supra-linear costs when recursively loading included workflows with deeply nested self-repeating motifs where the same workflow might be referenced multiple times.

Fixes #1680
Fixes #824

@glopesdev glopesdev added the fix Pull request that fixes an issue label Jul 8, 2024
@glopesdev glopesdev added this to the 2.8.4 milestone Jul 8, 2024
PathogenDavid
PathogenDavid previously approved these changes Jul 10, 2024
Copy link
Member

@PathogenDavid PathogenDavid left a comment

Choose a reason for hiding this comment

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

I'm limited in how much I can see far-reaching concerns here, but the changes look good to me. Just a few requests for clarity.

Bonsai.Core/WorkflowBuilder.cs Show resolved Hide resolved
Bonsai.Core/Expressions/IncludeWorkflowBuilder.cs Outdated Show resolved Hide resolved
Bonsai.Core/Expressions/IncludeWorkflowBuilder.cs Outdated Show resolved Hide resolved
Significant groundwork was required to avoid dependencies on the
instance field. Mostly this involved making all property serializer
methods static.
@glopesdev
Copy link
Member Author

glopesdev commented Jul 10, 2024

@PathogenDavid I ended up doing one final refactor to defer workflow assignment as you suggested in #824. Turns out the fix required significant groundwork to avoid depending on TypeDescriptor calls using this.

The refactoring in itself is definitely an improvement. I was a bit worried something might break, but thankfully the most complicated infrastructure was already in place and we have some test coverage of some of the most subtle edge cases which got triggered and fixed. I have also tested usage with some fairly complex workflows and everything seems to work fine.

@glopesdev glopesdev merged commit a2d7b4e into bonsai-rx:main Jul 10, 2024
10 checks passed
@glopesdev glopesdev deleted the issue-1680 branch July 10, 2024 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Pull request that fixes an issue
Projects
None yet
2 participants