You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@trafficserver.apache.org by "cmcfarlen (via GitHub)" <gi...@apache.org> on 2026/08/04 17:36:12 UTC

Re: [PR] Bound the ring walk of ParentConsistentHash::selectParent [trafficserver]

cmcfarlen commented on code in PR #13368:
URL: https://github.com/apache/trafficserver/pull/13368#discussion_r3714815587


##########
src/proxy/ParentConsistentHash.cc:
##########
@@ -151,6 +151,14 @@ ParentConsistentHash::selectParent(bool first_call, ParentResult *result, Reques
   HostStatus                &pStatus   = HostStatus::instance();
   TSHostStatus               host_stat = TSHostStatus::TS_HOST_STATUS_INIT;
 
+  // Bound the all-down ring walk: read each distinct parent's status at most once.
+  // Sized to the pool -- num_parents is not capped at MAX_PARENTS, so a fixed array would overflow.
+  int const         num_parents_in_ring[2] = {result->rec->num_parents, result->rec->num_secondary_parents};
+  std::vector<bool> seen_parent[2]         = {std::vector<bool>(num_parents_in_ring[PRIMARY]),
+                                              std::vector<bool>(num_parents_in_ring[SECONDARY])};

Review Comment:
   I don't like the allocation here.  Consider using ts::LocalBuffer or swoop::Vectray instead to try to avoid heap allocation here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscribe@trafficserver.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org