[PR #39] feat: optimize calculatePeerBandwidth to avoid nested loops #38

Open
opened 2025-11-19 07:03:51 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fosrl/gerbil/pull/39
Author: @LaurenceJJones
Created: 11/16/2025
Status: 🔄 Open

Base: mainHead: fix/calcpeerbandwidth-optimization


📝 Commits (2)

  • bba4345 main: optimize calculatePeerBandwidth to avoid nested peer scans
  • 971452e revert: drop logger formatting changes from calcpeerbandwidth optimization branch

📊 Changes

1 file changed (+6 additions, -8 deletions)

View changed files

📝 main.go (+6 -8)

📄 Description

Community Contribution License Agreement

By creating this pull request, I grant the project maintainers an unlimited,
perpetual license to use, modify, and redistribute these contributions under any terms they
choose, including both the AGPLv3 and the Fossorial Commercial license terms. I
represent that I have the right to grant this license for all contributed content.

Description

Build a set of current peer public keys during the primary iteration and prune lastReadings in a single pass, removing the O(n^2) nested loop.

How to test?

No behavior change; improves efficiency when peer lists and lastReadings grow large.

Whole function example calculation

With 5 peers:

old: 5 (primary) + O(5^2) = 30 passes
new: 5 (primary) + 5 (Secondary) = 10 passes

calculation are presumption pass loops had 5 peers and new iteration has same 5 peers


🔄 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/fosrl/gerbil/pull/39 **Author:** [@LaurenceJJones](https://github.com/LaurenceJJones) **Created:** 11/16/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/calcpeerbandwidth-optimization` --- ### 📝 Commits (2) - [`bba4345`](https://github.com/fosrl/gerbil/commit/bba4345b0fff4c3b93e0802cd1a722a17e674343) main: optimize calculatePeerBandwidth to avoid nested peer scans - [`971452e`](https://github.com/fosrl/gerbil/commit/971452e5d35dbc6a23f15a7f6e82d0bdc0c87e7c) revert: drop logger formatting changes from calcpeerbandwidth optimization branch ### 📊 Changes **1 file changed** (+6 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `main.go` (+6 -8) </details> ### 📄 Description ## Community Contribution License Agreement By creating this pull request, I grant the project maintainers an unlimited, perpetual license to use, modify, and redistribute these contributions under any terms they choose, including both the AGPLv3 and the Fossorial Commercial license terms. I represent that I have the right to grant this license for all contributed content. ## Description Build a set of current peer public keys during the primary iteration and prune lastReadings in a single pass, removing the O(n^2) nested loop. ## How to test? No behavior change; improves efficiency when peer lists and lastReadings grow large. Whole function example calculation With 5 peers: old: 5 (primary) + O(5^2) = 30 passes new: 5 (primary) + 5 (Secondary) = 10 passes _calculation are presumption pass loops had 5 peers and new iteration has same 5 peers_ --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-19 07:03:51 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gerbil#38