Skip to content

Conversation

@dmcgowan
Copy link
Member

SImplify and optimize graph logic

  • Unify added and disabled lookups to reduce the set lookups during graph walk
  • Avoid walking already handled registrations
  • Add circular dependency tracking during graph and panic with error including which plugin was first seen in the circle (previously graph would panic with stack overflow)
  • Add tests which include checking for errors
  • Add another check for invalid requires

Avoiding the extra walk by unifying the disabled/added is another significant performance improvement

benchmark              old ns/op     new ns/op     delta
BenchmarkGraph-14      28220         2271          -91.95%
BenchmarkUnique-14     23.5          23.3          -0.77%

benchmark              old allocs     new allocs     delta
BenchmarkGraph-14      8              5              -37.50%
BenchmarkUnique-14     0              0              +0.00%

benchmark              old bytes     new bytes     delta
BenchmarkGraph-14      5192          4552          -12.33%
BenchmarkUnique-14     0             0             +0.00%

And for fun, the benchcmp from the 1.0.0 version with this change and previous optimization

benchmark              old ns/op     new ns/op     delta
BenchmarkGraph-14      639154        2271          -99.64%
BenchmarkUnique-14     836           23.3          -97.21%

benchmark              old allocs     new allocs     delta
BenchmarkGraph-14      15020          5              -99.97%
BenchmarkUnique-14     14             0              -100.00%

benchmark              old bytes     new bytes     delta
BenchmarkGraph-14      725768        4552          -99.37%
BenchmarkUnique-14     672           0             -100.00%

@dmcgowan
Copy link
Member Author

I can rebase this after #14 and #15 are merged

Ensure that graph errors are handled as expected.

Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Derek McGowan <derek@mcg.dev>
Ensure circular dependencies are detected a panic with the plugin URI
that first experienced the circular dependency.

Signed-off-by: Derek McGowan <derek@mcg.dev>
This should be considered an invalid requirement

Signed-off-by: Derek McGowan <derek@mcg.dev>
@mxpv mxpv merged commit f351829 into containerd:main Dec 3, 2025
6 checks passed
@dmcgowan dmcgowan deleted the simplify-graph branch December 3, 2025 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants