[PR #1110] [MERGED] Fix excessive cpu usage #1887

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

📋 Pull Request Information

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

Base: mainHead: optimize_cpu


📝 Commits (1)

  • 8b2f4fb reflect.DeepEqual is a value copy that causes golang to continuously allocate memory

📊 Changes

2 files changed (+11 additions, -1 deletions)

View changed files

📝 machine.go (+1 -1)
📝 utils.go (+10 -0)

📄 Description

…allocate memory

  • 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

This pr modifies the comparison behavior of the containsAddresses function so that Golang does not continuously allocate memory and cause high cpu usage.

before_modification

after_modification


🔄 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/1110 **Author:** [@QZAiXH](https://github.com/QZAiXH) **Created:** 1/3/2023 **Status:** ✅ Merged **Merged:** 1/3/2023 **Merged by:** [@kradalby](https://github.com/kradalby) **Base:** `main` ← **Head:** `optimize_cpu` --- ### 📝 Commits (1) - [`8b2f4fb`](https://github.com/juanfont/headscale/commit/8b2f4fb613e66f2015d4aec9d4f2c0e6555a1b79) reflect.DeepEqual is a value copy that causes golang to continuously allocate memory ### 📊 Changes **2 files changed** (+11 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `machine.go` (+1 -1) 📝 `utils.go` (+10 -0) </details> ### 📄 Description …allocate memory <!-- 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. --> This pr modifies the comparison behavior of the `containsAddresses` function so that Golang does not continuously allocate memory and cause high cpu usage. ![before_modification](https://user-images.githubusercontent.com/23068780/210320172-b566d9fe-f409-4fd3-afad-995db16e0928.svg) ![after_modification](https://user-images.githubusercontent.com/23068780/210320281-7e4875fd-48f3-457d-90ce-3583757fd34e.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:38 +01:00
adam closed this issue 2025-12-29 03:18:38 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#1887