Skip to content

Use DeferAcyclicVerification() #13

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

Merged
merged 1 commit into from
Sep 11, 2024
Merged

Use DeferAcyclicVerification() #13

merged 1 commit into from
Sep 11, 2024

Conversation

joamaki
Copy link
Contributor

@joamaki joamaki commented Sep 11, 2024

uber/dig defaults to checking for cycles on each Provide() call, which on large graphs becomes pretty expensive (cilium-agent is getting into multiple seconds now). To speed things up, set the DeferAcyclicVerification option on the dig container (cycles are checked on each Invoke).

Here's the effect on TestAgentCells in cilium/cilium:

Before:

  daemon/cmd$ go test . -test.run TestAgentCell -test.count 1
  ok      github.com/cilium/cilium/daemon/cmd     3.674s

After:

  daemon/cmd$ go test . -test.run TestAgentCell -test.count 1
  ok      github.com/cilium/cilium/daemon/cmd     0.192s

uber/dig defaults to checking for cycles on each Provide() call, which
on large graphs becomes pretty expensive (cilium-agent is getting into
multiple seconds now). To speed things up, set the DeferAcyclicVerification
option on the dig container.

Here's the effect on TestAgentCells in cilium/cilium:

Before:
  daemon/cmd$ go test . -test.run TestAgentCell -test.count 1
  ok      github.com/cilium/cilium/daemon/cmd     3.674s

After:
  daemon/cmd$ go test . -test.run TestAgentCell -test.count 1
  ok      github.com/cilium/cilium/daemon/cmd     0.192s

Signed-off-by: Jussi Maki <[email protected]>
@joamaki joamaki requested a review from a team as a code owner September 11, 2024 12:24
@joamaki joamaki requested review from bimmlerd and removed request for a team September 11, 2024 12:24
Copy link
Member

@bimmlerd bimmlerd left a comment

Choose a reason for hiding this comment

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

// Applications adding providers to a container in a tight loop may experience
// performance improvements by initializing the container with this option.

I guess we fit the bill 😅

@joamaki joamaki merged commit f4191cd into main Sep 11, 2024
1 check passed
@joamaki joamaki deleted the pr/joamaki/defer-acyclic branch September 11, 2024 13:02
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.

2 participants