Skip to content

Commit a9324d7

Browse files
committed
adding logging for debugging purposes
1 parent 9711bad commit a9324d7

File tree

4 files changed

+75
-7
lines changed

4 files changed

+75
-7
lines changed

.github/workflows/run-bench.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,19 @@ jobs:
6565
java ${{ matrix.jdk >= 20 && '--enable-native-access=ALL-UNNAMED --add-modules=jdk.incubator.vector' || '' }} \
6666
${{ matrix.jdk >= 22 && '-Djvector.experimental.enable_native_vectorization=true' || '' }} \
6767
-jar jvector-examples/target/jvector-examples-*-jar-with-dependencies.jar io.github.jbellis.jvector.example.AutoBenchYAML --output bench-results.json ${{ inputs.benchmark_config != '' && inputs.benchmark_config || 'jvector-examples/yaml-configs/default.yml' }}
68+
69+
# List files in current directory to help with debugging
70+
echo "Files in current directory:"
71+
ls -la
6872
6973
- name: Upload Bench Results
7074
uses: actions/upload-artifact@v4
7175
with:
7276
name: bench-results-${{ matrix.isa }}-jdk${{ matrix.jdk }}
73-
path: bench-results.json
77+
path: |
78+
bench-results.json
79+
bench-results.log
80+
if-no-files-found: warn
7481

7582
- name: Download Previous Benchmark Results
7683
uses: dawidd6/action-download-artifact@v2

jvector-examples/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,17 @@
7272
</exclusion>
7373
</exclusions>
7474
</dependency>
75+
<!-- Add SLF4J and Logback for logging -->
76+
<dependency>
77+
<groupId>org.slf4j</groupId>
78+
<artifactId>slf4j-api</artifactId>
79+
<version>2.0.9</version>
80+
</dependency>
81+
<dependency>
82+
<groupId>ch.qos.logback</groupId>
83+
<artifactId>logback-classic</artifactId>
84+
<version>1.4.11</version>
85+
</dependency>
7586
<dependency>
7687
<groupId>software.amazon.awssdk</groupId>
7788
<artifactId>s3-transfer-manager</artifactId>

jvector-examples/src/main/java/io/github/jbellis/jvector/example/AutoBenchYAML.java

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
import io.github.jbellis.jvector.example.yaml.MultiConfig;
2525
import io.github.jbellis.jvector.graph.disk.feature.FeatureId;
2626

27+
import org.slf4j.Logger;
28+
import org.slf4j.LoggerFactory;
29+
2730
import java.io.File;
2831
import java.io.IOException;
2932
import java.util.ArrayList;
@@ -38,6 +41,8 @@
3841
* for regression testing in the run-bench.yml workflow.
3942
*/
4043
public class AutoBenchYAML {
44+
private static final Logger logger = LoggerFactory.getLogger(AutoBenchYAML.class);
45+
4146
/**
4247
* Returns a list of all dataset names.
4348
* This replaces the need to load datasets.yml which may not be available in all environments.
@@ -83,11 +88,11 @@ public static void main(String[] args) throws IOException {
8388
}
8489

8590
if (outputPath == null) {
86-
System.err.println("Error: --output argument is required for AutoBenchYAML");
91+
logger.error("Error: --output argument is required for AutoBenchYAML");
8792
System.exit(1);
8893
}
8994

90-
System.out.println("Heap space available is " + Runtime.getRuntime().maxMemory());
95+
logger.info("Heap space available is {}", Runtime.getRuntime().maxMemory());
9196

9297
// Filter out --output and its argument from the args
9398
String finalOutputPath = outputPath;
@@ -102,18 +107,21 @@ public static void main(String[] args) throws IOException {
102107

103108
var datasetNames = getAllDatasetNames().stream().filter(dn -> pattern.matcher(dn).find()).collect(Collectors.toList());
104109

105-
System.out.println("Executing the following datasets: " + datasetNames);
110+
logger.info("Executing the following datasets: {}", datasetNames);
106111
List<BenchResult> results = new ArrayList<>();
107112

108113
// Process datasets from regex patterns
109114
if (!datasetNames.isEmpty()) {
110115
for (var datasetName : datasetNames) {
116+
logger.info("Loading dataset: {}", datasetName);
111117
DataSet ds = DataSetLoader.loadDataSet(datasetName);
118+
logger.info("Dataset loaded: {} with {} vectors", datasetName, ds.baseVectors.size());
112119

113120
if (datasetName.endsWith(".hdf5")) {
114121
datasetName = datasetName.substring(0, datasetName.length() - ".hdf5".length());
115122
}
116123
MultiConfig config = MultiConfig.getDefaultConfig(datasetName);
124+
logger.info("Using configuration: {}", config);
117125

118126
results.addAll(Grid.runAllAndCollectResults(ds,
119127
config.construction.outDegree,
@@ -132,10 +140,14 @@ public static void main(String[] args) throws IOException {
132140
List<String> configNames = Arrays.stream(filteredArgs).filter(s -> s.endsWith(".yml")).collect(Collectors.toList());
133141
if (!configNames.isEmpty()) {
134142
for (var configName : configNames) {
143+
logger.info("Processing configuration file: {}", configName);
135144
MultiConfig config = MultiConfig.getConfig(configName);
136145
String datasetName = config.dataset;
146+
logger.info("Configuration specifies dataset: {}", datasetName);
137147

148+
logger.info("Loading dataset: {}", datasetName);
138149
DataSet ds = DataSetLoader.loadDataSet(datasetName);
150+
logger.info("Dataset loaded: {} with {} vectors", datasetName, ds.baseVectors.size());
139151

140152
results.addAll(Grid.runAllAndCollectResults(ds,
141153
config.construction.outDegree,
@@ -152,11 +164,19 @@ public static void main(String[] args) throws IOException {
152164

153165
// Calculate summary statistics
154166
SummaryStats stats = BenchmarkSummarizer.summarize(results);
155-
System.out.println(stats.toString());
167+
logger.info("Benchmark summary: {}", stats.toString());
156168

157169
// Write results to JSON file
158170
ObjectMapper mapper = new ObjectMapper();
159-
mapper.writerWithDefaultPrettyPrinter().writeValue(new File(outputPath), results);
160-
System.out.println("Benchmark results written to " + outputPath);
171+
File outputFile = new File(outputPath);
172+
mapper.writerWithDefaultPrettyPrinter().writeValue(outputFile, results);
173+
logger.info("Benchmark results written to {} (file exists: {})", outputPath, outputFile.exists());
174+
175+
// Double check that the file was created and log its size
176+
if (outputFile.exists()) {
177+
logger.info("Output file size: {} bytes", outputFile.length());
178+
} else {
179+
logger.error("Failed to create output file at {}", outputPath);
180+
}
161181
}
162182
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<!-- Console appender configuration -->
4+
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
5+
<!-- Ensure immediate flushing of logs -->
6+
<immediateFlush>true</immediateFlush>
7+
<encoder>
8+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
9+
</encoder>
10+
</appender>
11+
12+
<!-- File appender configuration -->
13+
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
14+
<file>bench-results.log</file>
15+
<append>true</append>
16+
<immediateFlush>true</immediateFlush>
17+
<encoder>
18+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
19+
</encoder>
20+
</appender>
21+
22+
<!-- Root logger configuration -->
23+
<root level="INFO">
24+
<appender-ref ref="CONSOLE" />
25+
<appender-ref ref="FILE" />
26+
</root>
27+
28+
<!-- Set specific logger levels -->
29+
<logger name="io.github.jbellis.jvector.example" level="DEBUG" />
30+
</configuration>

0 commit comments

Comments
 (0)