This is an automated email from the ASF dual-hosted git repository.

dlmarion pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/2.1 by this push:
     new d6ef7c8400 Attempt at reducing GC memory usage when gathering 
candidates (#6449)
d6ef7c8400 is described below

commit d6ef7c8400d9a90d251f7bafe94c4e1ed6c4ddb2
Author: Dave Marion <[email protected]>
AuthorDate: Tue Jun 30 07:23:34 2026 -0400

    Attempt at reducing GC memory usage when gathering candidates (#6449)
    
    This change pushes the Value filtering to the server-side
    using an iterator instead of using a filter in a Stream, and
    sets an initial size on the candidate ArrayList to try and
    reduce resize operations.
---
 .../server/metadata/GcCandidateFilter.java         | 33 ++++++++++++++++++++++
 .../accumulo/server/metadata/ServerAmpleImpl.java  |  5 ++--
 .../main/java/org/apache/accumulo/gc/GCRun.java    |  2 +-
 3 files changed, 37 insertions(+), 3 deletions(-)

diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/metadata/GcCandidateFilter.java
 
b/server/base/src/main/java/org/apache/accumulo/server/metadata/GcCandidateFilter.java
new file mode 100644
index 0000000000..146734395f
--- /dev/null
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/metadata/GcCandidateFilter.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.server.metadata;
+
+import org.apache.accumulo.core.data.Key;
+import org.apache.accumulo.core.data.Value;
+import org.apache.accumulo.core.iterators.Filter;
+import 
org.apache.accumulo.core.metadata.schema.MetadataSchema.DeletesSection.SkewedKeyValue;
+
+public class GcCandidateFilter extends Filter {
+
+  @Override
+  public boolean accept(Key k, Value v) {
+    return v.equals(SkewedKeyValue.NAME);
+  }
+
+}
diff --git 
a/server/base/src/main/java/org/apache/accumulo/server/metadata/ServerAmpleImpl.java
 
b/server/base/src/main/java/org/apache/accumulo/server/metadata/ServerAmpleImpl.java
index 22cb7a941f..b47a410396 100644
--- 
a/server/base/src/main/java/org/apache/accumulo/server/metadata/ServerAmpleImpl.java
+++ 
b/server/base/src/main/java/org/apache/accumulo/server/metadata/ServerAmpleImpl.java
@@ -36,6 +36,7 @@ import java.util.stream.StreamSupport;
 import org.apache.accumulo.core.client.BatchScanner;
 import org.apache.accumulo.core.client.BatchWriter;
 import org.apache.accumulo.core.client.IsolatedScanner;
+import org.apache.accumulo.core.client.IteratorSetting;
 import org.apache.accumulo.core.client.MutationsRejectedException;
 import org.apache.accumulo.core.client.Scanner;
 import org.apache.accumulo.core.client.TableNotFoundException;
@@ -60,7 +61,6 @@ import 
org.apache.accumulo.core.metadata.schema.ExternalCompactionFinalState;
 import org.apache.accumulo.core.metadata.schema.ExternalCompactionId;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.BlipSection;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.DeletesSection;
-import 
org.apache.accumulo.core.metadata.schema.MetadataSchema.DeletesSection.SkewedKeyValue;
 import 
org.apache.accumulo.core.metadata.schema.MetadataSchema.ExternalCompactionSection;
 import 
org.apache.accumulo.core.metadata.schema.MetadataSchema.ScanServerFileReferenceSection;
 import 
org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.BulkFileColumnFamily;
@@ -270,7 +270,8 @@ public class ServerAmpleImpl extends AmpleImpl implements 
Ample {
         throw new RuntimeException(e);
       }
       scanner.setRange(range);
-      return scanner.stream().filter(entry -> 
entry.getValue().equals(SkewedKeyValue.NAME))
+      scanner.addScanIterator(new IteratorSetting(25, "gcCandidate", 
GcCandidateFilter.class));
+      return scanner.stream()
           .map(
               entry -> new 
GcCandidate(DeletesSection.decodeRow(entry.getKey().getRow().toString()),
                   entry.getKey().getTimestamp()))
diff --git a/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java 
b/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
index 9c8b1da8b5..2a2261a8dd 100644
--- a/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
+++ b/server/gc/src/main/java/org/apache/accumulo/gc/GCRun.java
@@ -150,7 +150,7 @@ public class GCRun implements GarbageCollectionEnvironment {
     // Converting the bytes to approximate number of characters for batch size.
     long candidateBatchSize = getCandidateBatchSize() / 2;
 
-    List<GcCandidate> candidatesBatch = new ArrayList<>();
+    List<GcCandidate> candidatesBatch = new ArrayList<>(256);
     batchCount.incrementAndGet();
 
     while (candidates.hasNext()) {

Reply via email to