This is an automated email from the ASF dual-hosted git repository.
JingsongLi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 2da5af9ed1 [lumina] Stop writing LUMINA_EXECUTOR_THREAD_COUNT into the
JVM environment (#11242)
2da5af9ed1 is described below
commit 2da5af9ed168e8f155cdb5989f7e249e54efabce
Author: YangJie <[email protected]>
AuthorDate: Wed Nov 18 22:58:51 2026 -0500
[lumina] Stop writing LUMINA_EXECUTOR_THREAD_COUNT into the JVM environment
(#11242)
---
paimon-lumina/README.md | 2 +-
.../index/LuminaVectorGlobalIndexWriter.java | 63 ----------------------
.../lumina/index/LuminaVectorIndexOptions.java | 6 ++-
.../lumina/index/LuminaVectorGlobalIndexTest.java | 20 +++++++
.../index/LuminaVectorGlobalIndexWriterTest.java | 22 ++++++++
5 files changed, 48 insertions(+), 65 deletions(-)
diff --git a/paimon-lumina/README.md b/paimon-lumina/README.md
index a240593f58..feef158c3f 100644
--- a/paimon-lumina/README.md
+++ b/paimon-lumina/README.md
@@ -37,7 +37,7 @@ All options use the `lumina.` prefix as table properties.
| `lumina.pretrain.sample_ratio` | double | 0.2 | Sample ratio for pretraining
|
| `lumina.diskann.build.ef_construction` | int | 1024 | Size of the dynamic
candidate list during graph construction |
| `lumina.diskann.build.neighbor_count` | int | 64 | Maximum number of
neighbors per node in the graph |
-| `lumina.diskann.build.thread_count` | int | 32 | Number of threads used for
DiskANN index building |
+| `lumina.diskann.build.thread_count` | int | 32 | Number of threads used for
DiskANN index building. The build runs on Lumina's native executor, whose size
is read from the `LUMINA_EXECUTOR_THREAD_COUNT` environment variable of the
process (default 32); this option does not change it |
| `lumina.diskann.search.list_size` | int | 1.5x topK | DiskANN search list
size (auto-set to 1.5x topK if not specified) |
| `lumina.diskann.search.beam_width` | int | 4 | Beam width for DiskANN search
|
| `lumina.encoding.pq.m` | int | 64 | Number of sub-quantizers for PQ encoding
(auto-capped to dimension) |
diff --git
a/paimon-lumina/src/main/java/org/apache/paimon/lumina/index/LuminaVectorGlobalIndexWriter.java
b/paimon-lumina/src/main/java/org/apache/paimon/lumina/index/LuminaVectorGlobalIndexWriter.java
index f87761a113..ac52e418d5 100644
---
a/paimon-lumina/src/main/java/org/apache/paimon/lumina/index/LuminaVectorGlobalIndexWriter.java
+++
b/paimon-lumina/src/main/java/org/apache/paimon/lumina/index/LuminaVectorGlobalIndexWriter.java
@@ -39,14 +39,12 @@ import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
-import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.channels.FileChannel;
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
/**
* Vector global index writer using Lumina. Builds a single index file per
shard.
@@ -67,14 +65,6 @@ public class LuminaVectorGlobalIndexWriter implements
GlobalIndexSingleColumnWri
private static final Logger LOG =
LoggerFactory.getLogger(LuminaVectorGlobalIndexWriter.class);
- /**
- * Tracks which environment variables have already been set in this JVM.
Used to avoid
- * concurrent reflection-based modification of {@code System.getenv()}
when multiple shard tasks
- * run in parallel on the same TaskManager.
- */
- private static final ConcurrentHashMap<String, String> CONFIGURED_ENV_VARS
=
- new ConcurrentHashMap<>();
-
/** I/O buffer size for reading/writing the temp vector file (~8 MB). */
private static final int IO_BUFFER_SIZE = 8 * 1024 * 1024;
@@ -257,7 +247,6 @@ public class LuminaVectorGlobalIndexWriter implements
GlobalIndexSingleColumnWri
}
private ResultEntry buildIndex() throws IOException {
- configureExecutorThreadCount();
LOG.info(
"Lumina index build started: {} vectors, dim={}, type={},
metric={}",
count,
@@ -307,58 +296,6 @@ public class LuminaVectorGlobalIndexWriter implements
GlobalIndexSingleColumnWri
}
}
- /**
- * Sets the {@code LUMINA_EXECUTOR_THREAD_COUNT} environment variable from
the {@link
- * LuminaVectorIndexOptions#DISKANN_BUILD_THREAD_COUNT} option so the
native Lumina executor
- * thread pool is sized correctly before the builder is created.
- */
- private void configureExecutorThreadCount() {
- Map<String, String> luminaOpts = luminaOptions;
- String threadCountKey =
- LuminaVectorIndexOptions.toLuminaKey(
- LuminaVectorIndexOptions.DISKANN_BUILD_THREAD_COUNT);
- String threadCount = luminaOpts.get(threadCountKey);
- if (threadCount != null && !threadCount.isEmpty()) {
- setEnv("LUMINA_EXECUTOR_THREAD_COUNT", threadCount);
- }
- }
-
- /**
- * Best-effort, thread-safe, idempotent attempt to set an environment
variable in the current
- * process. Uses reflection to modify the JVM's process environment map.
This is necessary
- * because Lumina's native executor thread pool reads {@code
LUMINA_EXECUTOR_THREAD_COUNT} from
- * the OS environment.
- *
- * <p>When multiple shard tasks run in parallel on the same TaskManager
JVM, this method ensures
- * the reflection-based map modification happens at most once per
key-value pair.
- */
- @SuppressWarnings("unchecked")
- private static void setEnv(String key, String value) {
- // Skip if already set to the same value in this JVM
- if (value.equals(CONFIGURED_ENV_VARS.get(key))) {
- return;
- }
- synchronized (CONFIGURED_ENV_VARS) {
- // Double-check after acquiring lock
- if (value.equals(CONFIGURED_ENV_VARS.get(key))) {
- return;
- }
- try {
- Map<String, String> env = System.getenv();
- Field field = env.getClass().getDeclaredField("m");
- field.setAccessible(true);
- ((Map<String, String>) field.get(env)).put(key, value);
- CONFIGURED_ENV_VARS.put(key, value);
- } catch (Exception e) {
- LOG.warn(
- "Failed to set environment variable '{}' for Lumina
executor. "
- + "Thread-count tuning may not take effect.",
- key,
- e);
- }
- }
- }
-
private void checkDimension(int actualDim) {
if (actualDim != dim) {
throw new IllegalArgumentException(
diff --git
a/paimon-lumina/src/main/java/org/apache/paimon/lumina/index/LuminaVectorIndexOptions.java
b/paimon-lumina/src/main/java/org/apache/paimon/lumina/index/LuminaVectorIndexOptions.java
index 92727fd7f4..7c3f6eefaa 100644
---
a/paimon-lumina/src/main/java/org/apache/paimon/lumina/index/LuminaVectorIndexOptions.java
+++
b/paimon-lumina/src/main/java/org/apache/paimon/lumina/index/LuminaVectorIndexOptions.java
@@ -84,7 +84,11 @@ public class LuminaVectorIndexOptions {
ConfigOptions.key("lumina.diskann.build.thread_count")
.intType()
.defaultValue(32)
- .withDescription("Number of threads used for DiskANN index
building.");
+ .withDescription(
+ "Number of threads used for DiskANN index
building. The build runs"
+ + " on Lumina's native executor, whose
size is read from the"
+ + " environment variable
LUMINA_EXECUTOR_THREAD_COUNT of the"
+ + " process (default 32); this option does
not change it.");
public static final ConfigOption<Integer> DISKANN_SEARCH_LIST_SIZE =
ConfigOptions.key("lumina.diskann.search.list_size")
diff --git
a/paimon-lumina/src/test/java/org/apache/paimon/lumina/index/LuminaVectorGlobalIndexTest.java
b/paimon-lumina/src/test/java/org/apache/paimon/lumina/index/LuminaVectorGlobalIndexTest.java
index 6b5fbe3ee6..c9dd07fddb 100644
---
a/paimon-lumina/src/test/java/org/apache/paimon/lumina/index/LuminaVectorGlobalIndexTest.java
+++
b/paimon-lumina/src/test/java/org/apache/paimon/lumina/index/LuminaVectorGlobalIndexTest.java
@@ -652,6 +652,26 @@ public class LuminaVectorGlobalIndexTest {
}
}
+ @Test
+ public void testBuildDoesNotChangeExecutorThreadCountEnv() throws
IOException {
+ String envName = "LUMINA_EXECUTOR_THREAD_COUNT";
+ String before = System.getenv(envName);
+ Options options = createDefaultOptions(2);
+ options.setInteger(
+ LuminaVectorIndexOptions.DISKANN_BUILD_THREAD_COUNT.key(),
+ "7".equals(before) ? 8 : 7);
+
+ LuminaVectorGlobalIndexWriter writer =
+ new LuminaVectorGlobalIndexWriter(
+ createFileWriter(indexPath),
+ vectorType,
+ new LuminaVectorIndexOptions(options));
+ writer.write(new float[] {1.0f, 0.0f}, 0);
+ assertThat(writer.finish()).hasSize(1);
+
+ assertThat(System.getenv(envName)).isEqualTo(before);
+ }
+
@Test
public void testNullAtStart() throws IOException {
int dimension = 2;
diff --git
a/paimon-lumina/src/test/java/org/apache/paimon/lumina/index/LuminaVectorGlobalIndexWriterTest.java
b/paimon-lumina/src/test/java/org/apache/paimon/lumina/index/LuminaVectorGlobalIndexWriterTest.java
index ecae030045..87cd6b56ef 100644
---
a/paimon-lumina/src/test/java/org/apache/paimon/lumina/index/LuminaVectorGlobalIndexWriterTest.java
+++
b/paimon-lumina/src/test/java/org/apache/paimon/lumina/index/LuminaVectorGlobalIndexWriterTest.java
@@ -103,6 +103,28 @@ public class LuminaVectorGlobalIndexWriterTest {
}
}
+ @Test
+ public void testThreadCountIsPassedToBuildOptions() {
+ String key =
+ LuminaVectorIndexOptions.toLuminaKey(
+ LuminaVectorIndexOptions.DISKANN_BUILD_THREAD_COUNT);
+ Options options = createDefaultOptions(2);
+ assertThat(buildOptions(options)).containsEntry(key, "32");
+
+
options.setInteger(LuminaVectorIndexOptions.DISKANN_BUILD_THREAD_COUNT.key(),
7);
+ assertThat(buildOptions(options)).containsEntry(key, "7");
+ }
+
+ private static Map<String, String> buildOptions(Options options) {
+ try (LuminaVectorGlobalIndexWriter writer =
+ new LuminaVectorGlobalIndexWriter(
+ createNoopFileWriter(),
+ new VectorType(2, new FloatType()),
+ new LuminaVectorIndexOptions(options))) {
+ return writerLuminaOptions(writer);
+ }
+ }
+
private static Options createDefaultOptions(int dimension) {
Options options = new Options();
options.setInteger(LuminaVectorIndexOptions.DIMENSION.key(),
dimension);