Skip to content

Conversation

Alanxtl
Copy link
Contributor

@Alanxtl Alanxtl commented Oct 9, 2025

ref: #699
update content can refer to: https://github.com/Alanxtl/pixiu-router-update

benchmark result:

goos: windows
goarch: amd64
pkg: github.com/apache/dubbo-go-pixiu/pkg/common/router
cpu: AMD Ryzen 7 5800H with Radeon Graphics         
BenchmarkRouteReadThroughput/old/locked-read-30k-16                 7089            170887 ns/op           14797 B/op          7 allocs/op
BenchmarkRouteReadThroughput/new/rcu-read-30k-16                   25041             47645 ns/op             309 B/op          6 allocs/op
BenchmarkRouteReadParallel/old/parallel-30k-16                     45613             28601 ns/op           14824 B/op          7 allocs/op
BenchmarkRouteReadParallel/new/parallel-30k-16                    171332              8965 ns/op             310 B/op          6 allocs/op
BenchmarkReloadLatency/old/reload-1percent-30k-16                   1628            682656 ns/op          635355 B/op       6378 allocs/op
BenchmarkReloadLatency/new/reload-1percent-30k-16                   5469            214520 ns/op          301038 B/op        902 allocs/op
BenchmarkRoute100kReadThroughput/old/locked-read-100k-16            1218           1008264 ns/op           62400 B/op          8 allocs/op
BenchmarkRoute100kReadThroughput/new/rcu-read-100k-16               7696            164474 ns/op             310 B/op          6 allocs/op
BenchmarkRoute100kReadParallel/old/parallel-100k-16                10000            116339 ns/op           63567 B/op          8 allocs/op
BenchmarkRoute100kReadParallel/new/parallel-100k-16                56233             20846 ns/op             308 B/op          6 allocs/op
BenchmarkReload100kLatency1Percent/old/reload-1percent-100k-16               541           2267304 ns/op         2064730 B/op      21063 allocs/op
BenchmarkReload100kLatency1Percent/new/reload-1percent-100k-16              1419            796151 ns/op          973764 B/op       3001 allocs/op
BenchmarkRouteByPathAndName/old/RouteByPathAndName-16                    1231768               933.6 ns/op           429 B/op          9 allocs/op
BenchmarkRouteByPathAndName/new/RouteByPathAndName-16                    1419300               797.3 ns/op           429 B/op          9 allocs/op
PASS
ok      github.com/apache/dubbo-go-pixiu/pkg/common/router      24.883s

@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2025

Codecov Report

❌ Patch coverage is 31.06509% with 233 lines in your changes missing coverage. Please review.
✅ Project coverage is 15.81%. Comparing base (26606a8) to head (ba1ab0d).
⚠️ Report is 73 commits behind head on develop.

Files with missing lines Patch % Lines
pkg/model/router_snapshot.go 0.00% 100 Missing ⚠️
pkg/common/router/mock/router.go 0.00% 89 Missing ⚠️
pkg/common/router/router.go 84.67% 14 Missing and 5 partials ⚠️
pkg/common/util/stringutil/stringutil.go 0.00% 19 Missing ⚠️
pkg/model/router.go 0.00% 6 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (26606a8) and HEAD (ba1ab0d). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (26606a8) HEAD (ba1ab0d)
1 0
Additional details and impacted files
@@             Coverage Diff              @@
##           develop     #777       +/-   ##
============================================
- Coverage    54.67%   15.81%   -38.86%     
============================================
  Files          671      222      -449     
  Lines        78658    16628    -62030     
============================================
- Hits         43006     2630    -40376     
+ Misses       31981    13760    -18221     
+ Partials      3671      238     -3433     
Flag Coverage Δ
unittests 15.81% <31.06%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

sonarqubecloud bot commented Oct 9, 2025

@AlexStocks AlexStocks requested review from Copilot and mark4z and removed request for Copilot October 10, 2025 02:03
Copy link
Contributor

@Copilot 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 implements a new routing mechanism to improve performance by replacing the locked read/write approach with a Read-Copy-Update (RCU) pattern using atomic snapshots. The changes include introducing a snapshot-based routing system with debounced updates and optimized data structures.

Key changes:

  • Replaced mutex-based route coordination with atomic snapshot pattern
  • Added debounced route updates to batch changes and reduce overhead
  • Introduced optimized snapshot data structures with pre-compiled regex and method-specific tries

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/model/router_snapshot.go New snapshot data structures and compilation logic for lock-free routing
pkg/model/router.go Minor comment corrections and enhanced string representation for header-only routes
pkg/common/util/stringutil/stringutil.go Added utility function for generating trie keys with prefix support
pkg/common/router/router_test.go Comprehensive test suite comparing old vs new router implementations
pkg/common/router/router_bench_test.go Performance benchmarks demonstrating improvements in throughput and latency
pkg/common/router/router.go Complete rewrite of router coordinator using atomic snapshots and debounced updates
pkg/common/router/mock/router.go Mock implementation preserving old router behavior for comparison testing
pkg/common/http/manager_test.go Updated test configurations to use new router structure
pkg/common/constant/http.go Added constant for header value all levels pattern

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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