Skip to content

Commit bec7243

Browse files
authored
Merge pull request #276 from ebkalderon/fix-jsonl-parse-errors
Fix several regressions from adoption of JSONL file format
2 parents 9234c6a + a733d8c commit bec7243

9 files changed

Lines changed: 35 additions & 26 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,23 @@ jobs:
3939
run: |
4040
cd build
4141
cmake .. -DBUILD_BENCHMARKS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
42-
make -j$(nproc) toy lock_test
42+
make -j$(nproc) toy lock_test kmeans
4343
4444
- name: Verify build artifacts
4545
run: |
4646
test -f build/libcoz/libcoz.so
4747
test -x build/benchmarks/toy/toy
4848
test -x build/benchmarks/lock_test/lock_test
49+
test -x build/benchmarks/kmeans/kmeans
4950
echo "Build artifacts verified"
5051
52+
- name: Run unit tests
53+
run: |
54+
cd build
55+
ctest --output-on-failure -j$(nproc)
56+
rm -f profile.jsonl
57+
echo "Unit tests passed"
58+
5159
- name: Run toy benchmark with coz
5260
run: |
5361
cd build
@@ -115,7 +123,7 @@ jobs:
115123
obj = json.loads(line)
116124
if obj.get('type') == 'experiment':
117125
current_exp = obj
118-
elif obj.get('type') == 'throughput_point' and current_exp:
126+
elif obj.get('type') == 'throughput-point' and current_exp:
119127
current_exp['delta'] = float(obj['delta'])
120128
experiments.append(current_exp)
121129
current_exp = None
@@ -192,7 +200,7 @@ jobs:
192200
obj = json.loads(line)
193201
if obj.get('type') == 'experiment':
194202
current_exp = obj
195-
elif obj.get('type') == 'throughput_point' and current_exp:
203+
elif obj.get('type') == 'throughput-point' and current_exp:
196204
current_exp['delta'] = float(obj['delta'])
197205
experiments.append(current_exp)
198206
current_exp = None

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ libelfin/
3939

4040
viewer/node_modules
4141
rust/Cargo.lock
42-
rust/target
42+
rust/target/
43+
tests/rust_filter/Cargo.lock
44+
tests/rust_filter/target/
4345

4446
# CMake generated files
4547
CMakeLists.txt.user

benchmarks/check-output.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#!/bin/sh
22

33
set -e
4-
rm -f profile.coz
4+
rm -f profile.jsonl
55

66
$@
77

8-
grep -q "time=" profile.coz || { echo failure: valid profile.coz not generated; exit 1; }
9-
grep -q "throughput-point" profile.coz || { echo failure: throughput-point not found in profile; exit 1; }
10-
grep -q -P "samples\tlocation=" profile.coz || { echo failure: samples not found in profile; exit 1; }
11-
echo success: benchmark generated valid profile.coz
8+
grep -q '"time":' profile.jsonl || { echo failure: valid profile.jsonl not generated; exit 1; }
9+
grep -q '"throughput-point"' profile.jsonl || { echo failure: throughput-point not found in profile; exit 1; }
10+
grep -q -P '{"type":"samples","location":' profile.jsonl || { echo failure: samples not found in profile; exit 1; }
11+
echo success: benchmark generated valid profile.jsonl

coz

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ def parse_profile(profile_path, include_raw=False):
236236
'selected_samples': int(record.get('selected_samples', 0))
237237
}
238238
experiment_count += 1
239-
elif record_type == 'throughput_point':
239+
elif record_type == 'throughput-point':
240240
if experiment:
241241
selected = experiment['selected']
242242
speedup = experiment['speedup']

libcoz/profiler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ void profiler::profiler_thread(spinlock& l) {
400400
for(const auto& s : saved_throughput_points) {
401401
size_t delta = s->get_delta();
402402
if(_json_output) {
403-
output << "{\"type\":\"throughput_point\",\"name\":\"" << json_escape(s->get_name()) << "\","
403+
output << "{\"type\":\"throughput-point\",\"name\":\"" << json_escape(s->get_name()) << "\","
404404
<< "\"delta\":" << delta << "}\n";
405405
} else {
406406
s->log(output);
@@ -409,7 +409,7 @@ void profiler::profiler_thread(spinlock& l) {
409409

410410
for(const auto& s : saved_latency_points) {
411411
if(_json_output) {
412-
output << "{\"type\":\"latency_point\",\"name\":\"" << json_escape(s->get_name()) << "\","
412+
output << "{\"type\":\"latency-point\",\"name\":\"" << json_escape(s->get_name()) << "\","
413413
<< "\"arrivals\":" << s->get_begin_delta() << ","
414414
<< "\"departures\":" << s->get_end_delta() << ","
415415
<< "\"difference\":" << s->get_difference() << "}\n";

tests/run_dwarf_scope_test.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ run_profile() {
3030

3131
PROFILE_DEFAULT="$OUTDIR/profile-default.coz"
3232
run_profile "$PROFILE_DEFAULT"
33-
34-
grep -Eq '^samples[[:space:]]+location=.*dwarf_scope_test\.cpp' "$PROFILE_DEFAULT"
35-
if grep -Eq '/usr/(include|lib)/' "$PROFILE_DEFAULT"; then
36-
echo "unexpected system source in default profile" >&2
37-
exit 1
38-
fi
33+
grep -Eq '^{"type":"samples","location":.*dwarf_scope_test\.cpp' "$PROFILE_DEFAULT"
3934

4035
PROFILE_FILTERED="$OUTDIR/profile-filtered.coz"
4136
COZ_FILTER_SYSTEM=1 run_profile "$PROFILE_FILTERED"
42-
grep -Eq '^samples[[:space:]]+location=.*dwarf_scope_test\.cpp' "$PROFILE_FILTERED"
37+
grep -Eq '^{"type":"samples","location":.*dwarf_scope_test\.cpp' "$PROFILE_FILTERED"
38+
if grep -Eq '/usr/(include|lib)/' "$PROFILE_FILTERED"; then
39+
echo "unexpected system source in filtered profile" >&2
40+
exit 1
41+
fi

viewer/js/profile.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

viewer/js/profile.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

viewer/ts/profile.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ interface Experiment {
4040
}
4141

4242
interface ThroughputPoint {
43-
type: 'throughput-point' | 'progress-point' | 'throughput_point';
43+
type: 'throughput-point' | 'throughput_point' | 'progress-point';
4444
name: string;
4545
delta: number;
4646
}
4747

4848
interface LatencyPoint {
49-
type: 'latency-point';
49+
type: 'latency-point' | 'latency_point';
5050
name: string;
5151
arrivals: number;
5252
departures: number;
@@ -1023,11 +1023,11 @@ class Profile {
10231023
} else {
10241024
experiment = entry;
10251025
}
1026-
} else if (entry.type === 'throughput-point' || entry.type === 'progress-point' || entry.type === 'throughput_point') {
1026+
} else if (entry.type === 'throughput-point' || entry.type === 'throughput_point' || entry.type === 'progress-point') {
10271027
if (experiment !== null) {
10281028
this.addThroughputMeasurement(experiment, entry);
10291029
}
1030-
} else if (entry.type === 'latency-point') {
1030+
} else if (entry.type === 'latency-point' || entry.type === 'latency_point') {
10311031
if (experiment !== null) {
10321032
this.addLatencyMeasurement(experiment, entry);
10331033
}

0 commit comments

Comments
 (0)