-
Notifications
You must be signed in to change notification settings - Fork 239
Add generic depdency graph implementation to smithy-utils and use it for handling topological sorting #2774
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
JordonPhillips
wants to merge
3
commits into
main
Choose a base branch
from
plugin-ordering
base: main
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.
Conversation
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
JordonPhillips
commented
Sep 10, 2025
{ | ||
"type": "feature", | ||
"description": "Add a generic dependency graph to smithy-utils to be used for sorting various dependent objects, such as integrations and plugins.", | ||
"pull_requests": [] |
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.
I gotta update this
6740b0e
to
5eb3729
Compare
kstich
requested changes
Sep 11, 2025
...hy-codegen-core/src/jmh/java/software/amazon/smithy/codegen/core/jmh/SmithyIntegrations.java
Show resolved
Hide resolved
...hy-codegen-core/src/jmh/java/software/amazon/smithy/codegen/core/jmh/SmithyIntegrations.java
Show resolved
Hide resolved
...degen-core/src/main/java/software/amazon/smithy/codegen/core/IntegrationTopologicalSort.java
Outdated
Show resolved
Hide resolved
smithy-utils/src/main/java/software/amazon/smithy/utils/DependencyGraph.java
Outdated
Show resolved
Hide resolved
4bd3c5b
to
0a992d7
Compare
This adds a generic dependency graph to smithy-utils. This is intended to be used to sort SmithyIntegrations, SmithyBuildPlugins, and anything else that needs a topological sort.
This updates the SmithyIntegration sorting to use the generic DependencyGraph. It also adds some benchmarking configurations, which show a minor speed bump for highly dependent integrations and a major speed bump for highly independent integrations.
This adds the concept of dependencies to build plugins. Plugins can now declare that they must be run before or after some plugins. This uses the same dependency graph that is used by SmithyIntegration, but unlike integrations there is no concept of a "priority". This is because we may want to be able to run the plugins themselves in parallell, and such a priority would complicate that.
5e7393c
to
c74510b
Compare
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.
This adds a new
DependencyGraph
to smithy-utils, intended for use in the numerous locations where we perform topological sorts.Performance-wise, it's a bit faster for dense graphs (integrations with lots of dependencies) and a bit slower for sparse graphs. In the sizes we're realistically looking at for integrations (dozens, tops) the difference is insignificant. We're talking about a microsecond or two.
Here's benchmarking output for the old integration sort:

And here's output for the new:

I also plan to add the same sort of ordering capabilities to smithy build plugins, which is why I've gone to the trouble to make this generic.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.