[PR #1129] [MERGED] Repeat ToStringSlice #1900

Closed
opened 2025-12-29 03:18:41 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/juanfont/headscale/pull/1129
Author: @QZAiXH
Created: 1/11/2023
Status: Merged
Merged: 1/11/2023
Merged by: @juanfont

Base: mainHead: getFilteredByACLPeers


📝 Commits (1)

  • 1815f35 ToStringSlice will lead to high CPU usage, early conversion can reduce cpu usage

📊 Changes

1 file changed (+9 additions, -7 deletions)

View changed files

📝 machine.go (+9 -7)

📄 Description

…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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/juanfont/headscale/pull/1129 **Author:** [@QZAiXH](https://github.com/QZAiXH) **Created:** 1/11/2023 **Status:** ✅ Merged **Merged:** 1/11/2023 **Merged by:** [@juanfont](https://github.com/juanfont) **Base:** `main` ← **Head:** `getFilteredByACLPeers` --- ### 📝 Commits (1) - [`1815f35`](https://github.com/juanfont/headscale/commit/1815f3590126d2d3960d0455c04194047c8ff1d1) ToStringSlice will lead to high CPU usage, early conversion can reduce cpu usage ### 📊 Changes **1 file changed** (+9 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `machine.go` (+9 -7) </details> ### 📄 Description …e cpu usage <!-- Please tick if the following things apply. You… --> - [x] read the [CONTRIBUTING guidelines](README.md#contributing) - [ ] 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 <!-- If applicable, please reference the issue using `Fixes #XXX` and add tests to cover your new code. --> 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 03:18:41 +01:00
adam closed this issue 2025-12-29 03:18:41 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#1900