Skip to content

Fix ksrpc-bench compile rot and guard it in CI (#242) - #244

Merged
monkopedia-reviewer merged 1 commit into
mainfrom
fix/242-ksrpc-bench-compile
Jul 15, 2026
Merged

Fix ksrpc-bench compile rot and guard it in CI (#242)#244
monkopedia-reviewer merged 1 commit into
mainfrom
fix/242-ksrpc-bench-compile

Conversation

@monkopedia-coder

Copy link
Copy Markdown
Collaborator

Fixes #242.

Problem

:ksrpc-bench didn't compile. JniCommunicationBenchmark called a stale 3-arg JniConnection constructor and NativeHost.createEnv() / registerService() — externals with no native backing, left over from before the JNI host path was reworked in #204/#209. No CI job compiles :ksrpc-bench (JMH is never run in CI), so the drift went unnoticed until the 1.1.4 release build compiled the whole tree.

Fix

  • Rewrote the benchmark setup to use the current supported API — KsrpcNativeHost.connect(scope, TestNativeHost::initialize, env) — the same path the ksrpc-test JNI tests use. The native side registers the default TestJniImpl, so the timed /rpc round-trip is unchanged; only the untimed @Setup moves to the real entry point.
  • Replaced the dead NativeHost scaffolding (its serializeDeserialize/createContinuations/createContinuationRelay externals were unused by any benchmark) with a small TestNativeHost binding.
  • Added a compile-only :ksrpc-bench:compileKotlinJvm step to the jvm-tests CI job so the module can't silently rot again (JMH still not run in CI).

Verification

  • :ksrpc-bench compiles on all targets (jvm/js/linuxX64); ktlint clean.

  • Built the JMH jar + linuxX64 JNI library and ran the benchmark green (JDK 21):

    payloadSize throughput
    32 94.3 ± 2.6 ops/s
    256 94.0 ± 3.1 ops/s
    2048 91.1 ± 12.3 ops/s

    Quick config (1 fork / 1 warmup / 3 iters). Flat across payload sizes — the round-trip is dispatch/runBlocking-bound, not payload-bound — with no errors (-foe true). It measures the same operation as before, so no benchmark-semantics regression.

Non-published module; no API/ABI impact.

JniCommunicationBenchmark called a stale 3-arg JniConnection constructor plus
NativeHost.createEnv()/registerService() — externals with no native backing,
left over from before the JNI host path was reworked (#204/#209). This broke
`:ksrpc-bench` compilation, unnoticed because no CI job compiles the module.

Fix the benchmark to use the current API — KsrpcNativeHost.connect(scope,
TestNativeHost::initialize, env) — exactly as the ksrpc-test JNI tests do. This
registers the default TestJniImpl service, so the benchmarked `/rpc` round-trip
is unchanged (only the untimed @setup path moves to the supported entry point).
Replace the dead NativeHost scaffolding with a TestNativeHost binding.

Verified: the JMH benchmark builds and runs green against the linuxX64 JNI
library (~92-94 ops/s across payload sizes, dispatch-bound, no errors).

Also add a compile-only `:ksrpc-bench:compileKotlinJvm` step to the jvm-tests CI
job so the benchmarks can't silently rot again (JMH is still never run in CI).

Fixes #242.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

@monkopedia-reviewer monkopedia-reviewer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and approved.

Fix is correct: KsrpcNativeHost.connect(scope, TestNativeHost::initialize, env) is the right API — confirmed against KsrpcNativeHost.kt (3-arg form; environment has a default). The @CName("Java_com_monkopedia_ksrpc_TestNativeHost_initialize") in ksrpc-test/src/nativeMain/kotlin/Test.kt resolves the new object TestNativeHost binding correctly (package com.monkopedia.ksrpc, name mangling matches).

NativeHost deletion verified: No remaining references in ksrpc-bench/src. The NativeHost that still exists in ksrpc-test is a separate class with distinct native bindings for low-level JNI tests — unaffected.

Benchmark semantics unchanged: Only the untimed @Setup path changed; the @Benchmark fun jniRpcRoundTrip() is untouched.

CI guard is the right minimal prevention: :ksrpc-bench:compileKotlinJvm in jvm-tests catches future drift without running JMH.

All 5 CI checks green. Code is idiomatic and consistent with surrounding patterns.

@monkopedia-reviewer
monkopedia-reviewer merged commit 43b8883 into main Jul 15, 2026
5 checks passed
@monkopedia-reviewer
monkopedia-reviewer deleted the fix/242-ksrpc-bench-compile branch July 15, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ksrpc-bench fails to compile: stale JniConnection constructor call (module not built in CI)

3 participants