Skip to content
This repository was archived by the owner on Nov 21, 2026. It is now read-only.

JVM read path: fewer crossings per call (get_raw, one, count, lookup_by_key, transaction mark) - #524

Closed
tae898 wants to merge 6 commits into
mainfrom
perf/jvm-read-crossings
Closed

tae898 wants to merge 6 commits into
mainfrom
perf/jvm-read-crossings

Conversation

@tae898

@tae898 tae898 commented Oct 25, 2026

Copy link
Copy Markdown

The JVM wheel's read path crossed into the JVM several times per operation; a JPype call is a few microseconds of dispatch, and an untimed async-profiler pass (CPU samples of the Python-driven threads, main wheel) put 10.7% of a warm point-read workload in JNI/libjvm and 5.2% in JPype C++ besides 5.4% of Java glue. This PR cuts the number of crossings of five common calls, each as its own commit, with the answer, the errors and the result-set state unchanged.

What changes (crossings per call, counted by the new tests on a proxy of the Java object and the bridge classes; the tests that count fail on main and pass here)

Tests bindings/python/tests/test_read_crossings.py (21 tests: crossing counts plus equivalence with the plain path, including typed and composite keys, error cases and the engine's own stack numbers). On the main wheel 9 of them fail (the counts) and 12 pass (the equivalence); on this branch's wheel all 21 pass, and so do test_percall_calls, test_resultset, test_resultset_read_errors, test_results_after_close, test_run_in_transaction_retry, test_transaction_context_interrupt, test_transaction_config, test_graph_api, test_core, test_concurrency and test_cross_model_atomicity (232 passed, 10 skipped there). They ran against the main CI wheel with only the changed Python files and a bridge jar rebuilt from these sources. docs/development/bridge.md lists the new entry points.

What was measured and what was not Only untimed crossing counts. No speed claim is made here: a timed ABBA A/B of the main wheel against this branch on the benchmark laptop (point reads, one(), Document.get, small transactions and a 4-thread mixed window, with an A/A control and a rule written before the first timed run) is queued, and this PR is not to be merged on the counts alone. The transaction commit saves one crossing of a few microseconds next to a commit of tens of microseconds, so it may not show; the rule treats it separately.

🤖 Generated with Claude Code

tae898 and others added 6 commits October 25, 2026 17:00
… path

Counts the calls into the JVM of Document.get_raw, ResultSet.one() and count(), lookup_by_key and the transaction-stack mark, and pins that each answer, error and result-set state equals the plain path's. These fail on main: that is the change they ask for.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…has() then get()

get() answers null for a property the record does not have, as it does for one set to null; Python reads None either way, so the has() call only repeated the scan.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…st()

one() read hasNext()/next() per row and closed afterwards; count() crossed twice per row. upToTwoAndClose and countAndClose do the same work Java-side with the same errors and the same result-set state, and the plain path stays for a missing bridge class.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…no Java arrays

DbCalls.lookupFirstKey takes one key as scalars and lookupFirstKeys takes any number as the varargs of one call, so neither side builds a String[] and an Object[] per lookup. The engine receives the same arrays, and a different number of names and values reaches it as before.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The mark taken before every begin() (with db.transaction(), run_in_transaction) asked isTransactionActive() and getNestedTransactions() separately. DbCalls.stackMark returns both as one number. The mark is still taken before begin(), so the interrupt and refused-begin rules of ArcadeData#9970 and ArcadeData#9813 are unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@tae898

tae898 commented Oct 26, 2026

Copy link
Copy Markdown
Author

Closing here: the bindings moved to ArcadeData/arcadedb-python. The branch stays for the queued A/B jvm-readpath-glue-ab-laptop-20261025; if it passes, the change is ported there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant