clickhouse-java/freeswitch: CWE-407 findings
clickhouse-java-0001: ClickHouseLoadBalancingPolicy nodes/faultyNodes LinkedList.contains O(N*F) per node selection — fix: LinkedHashSet O(1). 120x speedup at F=500 faulty nodes. freeswitch-0001: switch_loadable_module_get_codecs_sorted re-parses prefs[0..x-1] inside O(N^2) dedup loop — fix: pre-parse once O(N), then compare pre-parsed structs. 13x speedup at N=50 (SWITCH_MAX_CODECS).
This commit is contained in:
parent
ac7030d9a7
commit
e9b981a309
4 changed files with 379 additions and 249 deletions
|
|
@ -0,0 +1,24 @@
|
|||
# UNDF: UNDF-2026-000000745
|
||||
# UNDF: (leave blank)
|
||||
--- a/clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseNodes.java
|
||||
+++ b/clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseNodes.java
|
||||
@@ -324,10 +324,10 @@ public class ClickHouseNodes implements ClickHouseNodeManager {
|
||||
* List of healthy nodes.
|
||||
*/
|
||||
- protected final LinkedList<ClickHouseNode> nodes;
|
||||
+ protected final LinkedHashSet<ClickHouseNode> nodes;
|
||||
/**
|
||||
* List of faulty nodes.
|
||||
*/
|
||||
- protected final LinkedList<ClickHouseNode> faultyNodes;
|
||||
+ protected final LinkedHashSet<ClickHouseNode> faultyNodes;
|
||||
|
||||
@@ -373,8 +373,8 @@ public class ClickHouseNodes implements ClickHouseNodeManager {
|
||||
this.checking = new AtomicBoolean(false);
|
||||
this.index = new AtomicInteger(0);
|
||||
this.lock = new ReentrantReadWriteLock();
|
||||
- this.nodes = new LinkedList<>(); // usually just healthy nodes
|
||||
- this.faultyNodes = new LinkedList<>();
|
||||
+ this.nodes = new LinkedHashSet<>(); // O(1) contains for load-balancing hot path
|
||||
+ this.faultyNodes = new LinkedHashSet<>(); // O(1) contains for health check
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue