Skip to content

Commit 11af34e

Browse files
committed
iter
1 parent 3ca7ef2 commit 11af34e

File tree

4 files changed

+64
-8
lines changed

4 files changed

+64
-8
lines changed

qa/vector/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ tasks.register("checkVec", JavaExec) {
3030
description = "Runs KnnIndexTester with the provided parameters to validate recall and performance."
3131
classpath = sourceSets.main.runtimeClasspath
3232
mainClass.set("org.elasticsearch.test.knn.KnnIndexTester")
33+
// Configure logging to console
34+
systemProperty "es.logger.out", "console"
35+
systemProperty "es.logger.level", "INFO" // Change to DEBUG if needed
36+
3337
if (buildParams.getRuntimeJavaVersion().map { it.majorVersion.toInteger() }.get() >= 21) {
3438
jvmArgs '-Xms4g', '-Xmx4g', '--add-modules=jdk.incubator.vector', '--enable-native-access=ALL-UNNAMED', '-Djava.util.concurrent.ForkJoinPool.common.parallelism=8', '-XX:+UnlockDiagnosticVMOptions', '-XX:+DebugNonSafepoints', '-XX:+HeapDumpOnOutOfMemoryError'
3539
}

qa/vector/src/main/java/org/elasticsearch/test/knn/KnnIndexTester.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.elasticsearch.index.codec.vectors.IVFVectorsFormat;
2121
import org.elasticsearch.index.codec.vectors.es818.ES818BinaryQuantizedVectorsFormat;
2222
import org.elasticsearch.index.codec.vectors.es818.ES818HnswBinaryQuantizedVectorsFormat;
23+
import org.elasticsearch.logging.Level;
2324
import org.elasticsearch.xcontent.XContentParser;
2425
import org.elasticsearch.xcontent.XContentParserConfiguration;
2526
import org.elasticsearch.xcontent.XContentType;
@@ -36,6 +37,10 @@
3637
* It supports various index types (HNSW, FLAT, IVF) and configurations.
3738
*/
3839
public class KnnIndexTester {
40+
static final Level LOG_LEVEL = Level.DEBUG;
41+
42+
static final SysOutLogger logger = new SysOutLogger();
43+
3944
static {
4045
LogConfigurator.loadLog4jPlugins();
4146
LogConfigurator.configureESLogging(); // native access requires logging to be initialized
@@ -305,4 +310,55 @@ static class Results {
305310
this.numDocs = numDocs;
306311
}
307312
}
313+
314+
static final class SysOutLogger {
315+
316+
void warn(String message) {
317+
if (LOG_LEVEL.ordinal() >= Level.WARN.ordinal()) {
318+
System.out.println(message);
319+
}
320+
}
321+
322+
void warn(String message, Object... params) {
323+
if (LOG_LEVEL.ordinal() >= Level.WARN.ordinal()) {
324+
System.out.println(String.format(Locale.ROOT, message, params));
325+
}
326+
}
327+
328+
void info(String message) {
329+
if (LOG_LEVEL.ordinal() >= Level.INFO.ordinal()) {
330+
System.out.println(message);
331+
}
332+
}
333+
334+
void info(String message, Object... params) {
335+
if (LOG_LEVEL.ordinal() >= Level.INFO.ordinal()) {
336+
System.out.println(String.format(Locale.ROOT, message, params));
337+
}
338+
}
339+
340+
void debug(String message) {
341+
if (LOG_LEVEL.ordinal() >= Level.DEBUG.ordinal()) {
342+
System.out.println(message);
343+
}
344+
}
345+
346+
void debug(String message, Object... params) {
347+
if (LOG_LEVEL.ordinal() >= Level.DEBUG.ordinal()) {
348+
System.out.println(String.format(Locale.ROOT, message, params));
349+
}
350+
}
351+
352+
void trace(String message) {
353+
if (LOG_LEVEL == Level.TRACE) {
354+
System.out.println(message);
355+
}
356+
}
357+
358+
void trace(String message, Object... params) {
359+
if (LOG_LEVEL == Level.TRACE) {
360+
System.out.println(String.format(Locale.ROOT, message, params));
361+
}
362+
}
363+
}
308364
}

qa/vector/src/main/java/org/elasticsearch/test/knn/KnnIndexer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
import org.apache.lucene.index.VectorSimilarityFunction;
3636
import org.apache.lucene.store.FSDirectory;
3737
import org.apache.lucene.util.PrintStreamInfoStream;
38-
import org.elasticsearch.logging.LogManager;
39-
import org.elasticsearch.logging.Logger;
4038

4139
import java.io.IOException;
4240
import java.io.UncheckedIOException;
@@ -54,8 +52,9 @@
5452
import java.util.concurrent.TimeUnit;
5553
import java.util.concurrent.atomic.AtomicInteger;
5654

55+
import static org.elasticsearch.test.knn.KnnIndexTester.logger;
56+
5757
class KnnIndexer {
58-
private static final Logger logger = LogManager.getLogger(KnnIndexer.class);
5958
private static final double WRITER_BUFFER_MB = 128;
6059
static final String ID_FIELD = "id";
6160
static final String VECTOR_FIELD = "vector";

qa/vector/src/main/java/org/elasticsearch/test/knn/KnnSearcher.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
import org.apache.lucene.store.FSDirectory;
4242
import org.apache.lucene.store.MMapDirectory;
4343
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper;
44-
import org.elasticsearch.logging.LogManager;
45-
import org.elasticsearch.logging.Logger;
4644
import org.elasticsearch.search.profile.query.QueryProfiler;
4745
import org.elasticsearch.search.vectors.ESKnnByteVectorQuery;
4846
import org.elasticsearch.search.vectors.ESKnnFloatVectorQuery;
@@ -74,13 +72,12 @@
7472
import java.util.concurrent.TimeUnit;
7573

7674
import static org.apache.lucene.search.DocIdSetIterator.NO_MORE_DOCS;
75+
import static org.elasticsearch.test.knn.KnnIndexTester.logger;
7776
import static org.elasticsearch.test.knn.KnnIndexer.ID_FIELD;
7877
import static org.elasticsearch.test.knn.KnnIndexer.VECTOR_FIELD;
7978

8079
class KnnSearcher {
8180

82-
private static final Logger logger = LogManager.getLogger(KnnIndexTester.class);
83-
8481
private final Path docPath;
8582
private final Path indexPath;
8683
private final Path queryPath;
@@ -172,7 +169,7 @@ void runSearch(KnnIndexTester.Results finalResults) throws IOException {
172169
resultIds[i] = getResultIds(results[i], storedFields);
173170
}
174171
logger.info(
175-
"completed {} searches in {} ms: {} QPS CPU time={}ms",
172+
"completed %d searches in %d ms: %d QPS CPU time=%dms",
176173
numQueryVectors,
177174
elapsed,
178175
(1000L * numQueryVectors) / elapsed,

0 commit comments

Comments
 (0)