Kotlin spike - #1
Open
MDA2AV wants to merge 2 commits into
Open
Conversation
… over Panama ioma_route_ffi registers a plain C function pointer with a flat, padding-free request (ten 8-byte fields) and reply (32 bytes) so any binding can lay them out. Such a handler must not run on a coroutine's 64 KB stack (a JVM bounds-checks and walks the thread's real stack), so the coroutine parks with await_call and the loop runs it on the worker's own thread stack, then resumes the coroutine with the reply. Every resume goes through run_coro, which services those calls. Middleware still wraps foreign endpoints. playground/kotlin: Server.kt loads libioma.so through java.lang.foreign, turns two Kotlin functions into upcall stubs, registers them and hands the main thread to ioma_run. Allocation-free on the hot path; reads the request and writes the reply straight in C memory. Verified: a C test asserts the handler lands on the 8 MB thread stack; sums, chunked bodies, 404 and the fragmentation sweep pass from Kotlin. On 4 pinned cores the Kotlin handler does ~1.18M req/s vs ~1.26M native (JDK 26.0.2.1). Claude-Session: https://claude.ai/code/session_013wYnJvEFUjKEpGLkyTLt9P
One upcall dispatcher serves every route (the route index rides in userdata), per-thread Request/Reply wrappers hide the offsets and reinterprets, and the app is just routes with lambdas. Same throughput as the hand-rolled version (~1.17M req/s on 4 cores, JDK 26); sums, chunked, 404 and the fragmentation sweep pass. Claude-Session: https://claude.ai/code/session_013wYnJvEFUjKEpGLkyTLt9P
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.