GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Parse the correlator's command line with picocli (#8) · jonoffcpu/jonoffcpu@847e8b6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • README.md
  • jonoffcpu-correlator
    • OFFLINE.md
    • build.gradle.kts
    • src
      • main/java/io/github/lhotari/jonoffcpu/offline
        • Cli.java
        • OffCpuCorrelator.java
      • test
        • java/io/github/lhotari/jonoffcpu/offline
          • CommandLineTest.java
          • PartialCorrelatorTest.java
          • StackProfileTest.java
        • resources/help
          • correlate.txt
          • dump.txt
          • export.txt
          • jonoffcpu-correlator.txt
          • merge.txt
          • stacks.txt
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎README.md‎

Copy file name to clipboardExpand all lines: README.md
+7-1Lines changed: 7 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ Capture, written by the agent next to `correlationOutput` (the examples assume
201201

202202
| File | Contents | Name comes from |
203203
| --- | --- | --- |
204-
| `jonoffcpu-capture.pb` | The correlation stream: `captureStart`, one `stack` per distinct native stack, one `observation` per recorded off-CPU interval referencing them by id, `captureEnd`, and the `captureFinalized` footer that binds the JFR's size and SHA-256. Length-delimited protobuf, defined by [`docs/schema/jonoffcpu-capture.proto`](docs/schema/jonoffcpu-capture.proto); `java -jar jonoffcpu-correlator.jar --dump --source <file>` prints it as NDJSON | `correlationOutput` |
204+
| `jonoffcpu-capture.pb` | The correlation stream: `captureStart`, one `stack` per distinct native stack, one `observation` per recorded off-CPU interval referencing them by id, `captureEnd`, and the `captureFinalized` footer that binds the JFR's size and SHA-256. Length-delimited protobuf, defined by [`docs/schema/jonoffcpu-capture.proto`](docs/schema/jonoffcpu-capture.proto); `java -jar jonoffcpu-correlator.jar dump --source <file>` prints it as NDJSON | `correlationOutput` |
205205
| `jonoffcpu-capture.manifest.json` | Audit manifest: configuration, resolved sampling policy, artifact paths, lifecycle state, completion flag | the stem of `correlationOutput` + `.manifest.json` |
206206
| `jonoffcpu-capture.jfr` | The combined async-profiler recording, including `profiler.SignalSample` events | the `file=` option in `asyncProfilerOptions`; defaults to the stem of `correlationOutput` + `.jfr` |
207207

@@ -902,6 +902,12 @@ and the stack profile's entries — retention
902902
tracks distinct stacks, not capture length, so a long capture with few distinct
903903
call paths costs little more than a short one.
904904

905+
`java -jar jonoffcpu-correlator.jar help <command>` (or `<command> --help`)
906+
prints every option of a command with its default, and `--version` the build
907+
and the async-profiler fork commit. The correlator exits with status 0 for a
908+
complete result, 2 for narrowed or partial output, and 64 for an invalid
909+
command line, which it reports with the command's usage.
910+
905911
By default the correlator refuses a JFR whose size or SHA-256 differs from the
906912
one recorded in the stream's footer. The full output, integrity, and weighting
907913
contracts are in [jonoffcpu-correlator/OFFLINE.md](jonoffcpu-correlator/OFFLINE.md).
Collapse file

‎jonoffcpu-correlator/OFFLINE.md‎

Copy file name to clipboardExpand all lines: jonoffcpu-correlator/OFFLINE.md
+5-2Lines changed: 5 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ sleeping/run-queue split, and 2 for captures recorded before switch-out reasons
1717
were classified, both still read), and that JSON is still read with the strict
1818
parser; observations and stacks are native protobuf.
1919
All control records of one capture carry the same version. Read a capture with
20-
`java -jar jonoffcpu-correlator.jar --dump --source <file>`, which prints one
20+
`java -jar jonoffcpu-correlator.jar dump --source <file>` (formerly `--dump --source`,
21+
still accepted), which prints one
2122
JSON object per record with each observation's stacks expanded.
2223

2324
Stacks are interned: an observation names its two stacks through
@@ -501,7 +502,9 @@ java -jar jonoffcpu-correlator.jar \
501502
```
502503

503504
A successfully written partial diagnostic run exits with **status 2**. Complete
504-
analysis exits with status 0; errors exit with status 1. Partial mode never promotes
505+
analysis exits with status 0; an invalid command line exits with status 64 after
506+
printing the problem and the command's usage, and other errors exit with status 1.
507+
Partial mode never promotes
505508
its result to complete, even if the supplied inputs happen to be finalized.
506509
Its new output directory holds a visibly different file set:
507510

Collapse file

‎jonoffcpu-correlator/build.gradle.kts‎

Copy file name to clipboardExpand all lines: jonoffcpu-correlator/build.gradle.kts
+44-3Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,42 @@ dependencies {
5959
embeddedRuntime("com.google.protobuf:protobuf-javalite:4.33.1")
6060
embeddedRuntime("com.google.code.gson:gson:2.14.0")
6161
embeddedRuntime("org.openjdk.jmc:flightrecorder.writer:9.1.2")
62+
embeddedRuntime("info.picocli:picocli:4.7.7")
6263
jmcWriterSources("org.openjdk.jmc:flightrecorder.writer:9.1.2:sources@jar")
6364
}
6465

66+
// The build version and the async-profiler fork commit, for --version.
67+
val asyncProfilerCommit =
68+
providers
69+
.exec {
70+
// The pinned gitlink, which is what the build embeds whether or not the submodule is checked out.
71+
commandLine("git", "-C", rootProject.projectDir.absolutePath, "rev-parse", "HEAD:async-profiler")
72+
isIgnoreExitValue = true
73+
}.standardOutput.asText
74+
.map { it.trim().ifEmpty { "unknown" } }
75+
val generateVersionResource =
76+
tasks.register("generateVersionResource") {
77+
val version = project.version.toString()
78+
val commit = asyncProfilerCommit
79+
val outputDir = layout.buildDirectory.dir("generated/version-resource")
80+
inputs.property("version", version)
81+
inputs.property("asyncProfilerCommit", commit)
82+
outputs.dir(outputDir)
83+
doLast {
84+
val file =
85+
outputDir
86+
.get()
87+
.file("io/github/lhotari/jonoffcpu/offline/version.properties")
88+
.asFile
89+
file.parentFile.mkdirs()
90+
file.writeText("version=$version\nasyncProfilerCommit=${commit.get()}\n")
91+
}
92+
}
93+
6594
sourceSets {
6695
main {
6796
proto.setSrcDirs(listOf(rootProject.layout.projectDirectory.dir("docs/schema")))
97+
resources.srcDir(generateVersionResource)
6898
}
6999
}
70100

@@ -106,6 +136,7 @@ val buildAsyncProfilerConverter = tasks.register<Exec>("buildAsyncProfilerConver
106136
val expectedDependencyDigests = mapOf(
107137
"protobuf-javalite-4.33.1.jar" to "a1a1cccbcfa861e988b7ccde58dbe95204156906dd6cd42786b9c8f74d5fe34e",
108138
"gson-2.14.0.jar" to "2cbd119bf1961c28788310963dc80ba65f58cdeec1dd139c8bdb1240faa2c36f",
139+
"picocli-4.7.7.jar" to "f86e30fffd10d2b13b8caa8d4b237a7ee61f2ffccf5b1941de718b765d235bf8",
109140
"flightrecorder.writer-9.1.2.jar" to
110141
"8313e66f798f31de144c65b257a0434afca07b1bce1b59f17e63aed38c0dc9c1",
111142
"flightrecorder.writer-9.1.2-sources.jar" to
@@ -127,7 +158,7 @@ fun sha256File(input: File): String {
127158

128159
val verifyDependencyDigests = tasks.register("verifyDependencyDigests") {
129160
group = "verification"
130-
description = "Checks the exact protobuf, Gson and patched JMC writer artifacts before embedding them."
161+
description = "Checks the exact protobuf, Gson, picocli and patched JMC writer artifacts before embedding them."
131162
inputs.files(embeddedRuntime, jmcWriterSources)
132163
doLast {
133164
(embeddedRuntime.files + jmcWriterSources.files).forEach { artifact ->
@@ -184,6 +215,7 @@ val jar = tasks.named<ShadowJar>("shadowJar") {
184215
relocate("com.google.protobuf", "io.github.lhotari.jonoffcpu.correlator.internal.shaded.protobuf")
185216
relocate("com.google.gson", "io.github.lhotari.jonoffcpu.correlator.internal.shaded.gson")
186217
relocate("org.openjdk.jmc", "io.github.lhotari.jonoffcpu.correlator.internal.shaded.jmc")
218+
relocate("picocli", "io.github.lhotari.jonoffcpu.correlator.internal.shaded.picocli")
187219
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
188220
isPreserveFileTimestamps = false
189221
isReproducibleFileOrder = true
@@ -235,14 +267,16 @@ val verifyRuntimeJar = tasks.register("verifyRuntimeJar") {
235267
it.name.startsWith("com/google/gson/")
236268
|| it.name.startsWith("org/openjdk/jmc/")
237269
|| it.name.startsWith("com/google/protobuf/")
270+
|| it.name.startsWith("picocli/")
238271
}) {
239272
throw GradleException("Correlator JAR contains unrelocated dependency packages")
240273
}
241274
listOf(
242275
"io/github/lhotari/jonoffcpu/correlator/internal/shaded/gson/Gson.class",
243276
"io/github/lhotari/jonoffcpu/correlator/internal/shaded/protobuf/CodedInputStream.class",
244277
"io/github/lhotari/jonoffcpu/correlator/internal/shaded/jmc/flightrecorder/writer/api/Recordings.class",
245-
"io/github/lhotari/jonoffcpu/correlator/internal/shaded/jmc/flightrecorder/writer/ConstantPool.class"
278+
"io/github/lhotari/jonoffcpu/correlator/internal/shaded/jmc/flightrecorder/writer/ConstantPool.class",
279+
"io/github/lhotari/jonoffcpu/correlator/internal/shaded/picocli/CommandLine.class"
246280
).forEach { name ->
247281
if (zip.getEntry(name) == null) throw GradleException("Correlator JAR is missing relocated class $name")
248282
}
@@ -259,7 +293,8 @@ val fixtureMains = mapOf(
259293
"PartialCorrelator" to "io.github.lhotari.jonoffcpu.offline.PartialCorrelatorTest",
260294
"PrimitiveStructures" to "io.github.lhotari.jonoffcpu.offline.PrimitiveStructuresTest",
261295
"StreamingCorrelator" to "io.github.lhotari.jonoffcpu.offline.StreamingCorrelatorTest",
262-
"StackProfile" to "io.github.lhotari.jonoffcpu.offline.StackProfileTest"
296+
"StackProfile" to "io.github.lhotari.jonoffcpu.offline.StackProfileTest",
297+
"CommandLine" to "io.github.lhotari.jonoffcpu.offline.CommandLineTest"
263298
)
264299
val fixtureTasks = fixtureMains.map { (taskName, className) ->
265300
tasks.register<JavaExec>("test$taskName") {
@@ -274,6 +309,12 @@ val fixtureTasks = fixtureMains.map { (taskName, className) ->
274309

275310
// Spec acceptance 4: the scale fixture's assertion is the heap cap itself, so it must run under
276311
// exactly the bound it proves, not whatever heap the other fixtures happen to get.
312+
// The README's option tables are checked against the parser, so documentation and help cannot drift.
313+
tasks.named<JavaExec>("testCommandLine") {
314+
inputs.file(rootProject.file("README.md"))
315+
systemProperty("jonoffcpu.readme", rootProject.file("README.md").absolutePath)
316+
}
317+
277318
tasks.named<JavaExec>("testStreamingCorrelator") {
278319
jvmArgs("-ea", "-Xmx1g")
279320
}

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.