Commit e8dfce8
authored
feat(hostport): implement port-reuse with least-used allocation strategy (#327)
* feat: implement sharded lock for HostPort port allocation
- Add ShardCount config option for customizable shard count
- Replace global mutex with per-shard locks to reduce contention
- Use FNV-1a hash for consistent shard routing by GSS name
- Support parallel port allocation across different shards
- Default shard_count=1 for backward compatibility
* feat(hostport): optimize concurrent port allocation with lock-free design
- Replace sharded port pools with shared port pool
- Use sync.Map for lock-free port lookup
- Use atomic operations for port usage counting
- Sharded locks only for pod allocation records
- Change sharding key from GSS name to GS name for better distribution
- Increase MaxShardCount from 128 to 256
This optimization reduces lock contention from 100% to ~0.4% in
high-concurrency scenarios (500 workers).
* feat(hostport): implement port-reuse with least-used allocation strategy
- Replace portAmount/amountStat with portUsage counter array
- Implement least-used allocation for cross-node port reuse
- Remove unused shard_count config option
- Fix unused attrIntValue in nodeport_test.go (lint)1 parent 801f5a2 commit e8dfce8
5 files changed
Lines changed: 640 additions & 489 deletions
File tree
- cloudprovider/kubernetes
- docs/proposals
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
0 commit comments