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

Repeat ToStringSlice #1129

Merged
merged 1 commit into from
Jan 11, 2023
Merged

Repeat ToStringSlice #1129

merged 1 commit into from
Jan 11, 2023

Conversation

QZAiXH
Copy link
Contributor

@QZAiXH QZAiXH commented Jan 11, 2023

…e cpu usage

  • read the CONTRIBUTING guidelines
  • raised a GitHub issue or discussed it on the projects chat beforehand
  • added unit tests
  • added integration tests
  • updated documentation if needed
  • updated CHANGELOG.md

I've been watching the cpu situation for the past few days, and I found that the cpu occasionally suddenly rises to 500%, so I used pprof to check and found that ToStringSlice causes the cpu to rise.

After optimizing it, the cpu is still rising occasionally, but not very much.

The final solution should be to use the cache to store the machine information for comparison, and modify the database data and cache information only when there are changes. I'm not familiar with it, so I haven't made the appropriate changes yet.

https://user-images.githubusercontent.com/23068780/210695313-54af7475-d527-4274-b33a-50838c44ed98.svg
https://user-images.githubusercontent.com/23068780/210695393-754f2a55-6894-42ac-8ecc-6294109e2f19.svg

Copy link
Owner

@juanfont juanfont left a comment

Choose a reason for hiding this comment

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

Looks cool!

@juanfont
Copy link
Owner

This will probably help in #1014.

@QZAiXH
Copy link
Contributor Author

QZAiXH commented Jan 11, 2023

This will probably help in #1014.

Yes, the 2-core CPU is now driving 550 machines. The cpu usage is currently a third of what it was before.
But this is not the optimal solution, after that I will try to replace gorm's queries with cache.

@juanfont juanfont merged commit a6c8718 into juanfont:main Jan 11, 2023
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