Skip to content

Conversation

@alespour
Copy link
Collaborator

@alespour alespour commented Apr 9, 2025

No description provided.

@alespour alespour force-pushed the fix/reduce-route-dispatch-allocations branch from 067bbff to ee146f3 Compare April 10, 2025 14:38
@alespour alespour marked this pull request as ready for review April 25, 2025 11:56
@alespour alespour requested a review from Copilot April 25, 2025 11:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR aims to reduce route dispatch allocations by refactoring the router’s handler slice allocation and adding a benchmark to test the performance of matchAndDispatch.

  • Added Benchmark_MatchAndDispatch in unit_router_test.go
  • Moved the declaration of the handlers slice outside the message processing loop in router.go
  • Cleared the handlers slice in each loop iteration to reuse allocated memory

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
unit_router_test.go Added a benchmark test (Benchmark_MatchAndDispatch) for performance evaluation.
router.go Moved the handlers slice declaration outside the loop and cleared it to reduce allocations.
Comments suppressed due to low confidence (1)

unit_router_test.go:381

  • The field name 'oboundP' in the client struct may be a typo. Verify if the intended name is 'outboundP' to improve code clarity.
&client{oboundP: make(chan *PacketAndToken, 100)}

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