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

init rand once #65

Merged

Conversation

Shmillerov
Copy link
Contributor

I did performance testing with fanout plugin and was found that rand.NewSource uses 4.3% of CPU
image

Here is a fix that moves rand initialization to weightedPolicy, so that rand is initialized only once.

Profile after the fix

image

Signed-off-by: Viktor Rodionov <[email protected]>
Copy link
Member

@denis-tingaikin denis-tingaikin left a comment

Choose a reason for hiding this comment

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

Looks good. Is it possible to add a regression test?

Signed-off-by: Viktor Rodionov <[email protected]>
@Shmillerov
Copy link
Contributor Author

Is it possible to add a regression test?

Hello. What do you mean? All tests are passed. Also I tested it manually. Based on that there is no regression. You want to add more scenarios?

@denis-tingaikin
Copy link
Member

If we fixed a problem, it would be beneficial to add coverage for the issue to ensure that the developed and tested software continues to function as expected even after future changes.

So, is it possible to add a test that covers the problem?

@Shmillerov
Copy link
Contributor Author

This is not a functional issue. Before that everything worked correctly. It's just an improvement: initialization before was performed for each request, now - only once. From a functional point of view, nothing has changed. Because of this, the current tests cover the necessary functionality.

@denis-tingaikin denis-tingaikin merged commit be13596 into networkservicemesh:main Nov 8, 2024
13 checks passed
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