You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2026/08/25 14:51:00 UTC
[jira] [Updated] (HDDS-16279) Cache replica index map in Pipeline
[ https://issues.apache.org/jira/browse/HDDS-16279?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
ASF GitHub Bot updated HDDS-16279:
----------------------------------
Labels: pull-request-available (was: )
> Cache replica index map in Pipeline
> -----------------------------------
>
> Key: HDDS-16279
> URL: https://issues.apache.org/jira/browse/HDDS-16279
> Project: Apache Ozone
> Issue Type: Sub-task
> Reporter: Huang Kuan Hao
> Assignee: Huang Kuan Hao
> Priority: Major
> Labels: pull-request-available
>
> Pipeline is immutable, but getReplicaIndexes() re-derives a map (list + toMap + boxing) on every call, on the per-block-read command-build path:
> public Map<DatanodeDetails, Integer> getReplicaIndexes() {
> return this.getNodes().stream()
> .collect(Collectors.toMap(Function.identity(), this::getReplicaIndex));
> }
> Fix: memoize the derived map with a lazy holder:
> private volatile Map<DatanodeDetails, Integer> replicaIndexesView;
> public Map<DatanodeDetails, Integer> getReplicaIndexes() {
> Map<DatanodeDetails, Integer> v = replicaIndexesView;
> if (v == null) {
> v = getNodes().stream().collect(Collectors.toMap(Function.identity(), this::getReplicaIndex));
> replicaIndexesView = v; // benign race; Pipeline is immutable
> }
> return v;
> }
> Note: cache the derived map — it covers all nodes with a 0 default (getReplicaIndex), unlike the internal replicaIndexes field (explicit-index nodes only). Do not return the field. Behavior unchanged.
> File: hadoop-hdds/common/.../hdds/scm/pipeline/Pipeline.java:247
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org