Skip to content

perf(core): cut PostgreSQL and MySQL round trips, cap FFI workers, and fix slow Linux grid deletes and highlights - #4224

Merged
datlechin merged 5 commits into
mainfrom
fix/perf-rust-core-linux
Nov 12, 2026
Merged

datlechin merged 5 commits into
mainfrom
fix/perf-rust-core-linux

Conversation

@datlechin

@datlechin datlechin commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

Performance audit 2026-11-11, Rust core and Linux items. Round trips are counted on the wire with a new test transport (RoundTripCounter), against PostgreSQL 17 and MySQL 8.4 in Docker.

  • RS-01, PostgreSQL editor: a row-limited statement goes in two pipelined flights, the open with the DECLARE (and the origin lookup), then the FETCH with COMMIT, or with CLOSE and RELEASE inside the user's transaction. A failed open fails the DECLARE before it plans anything, so nothing runs outside the read-only transaction. A COMMIT that errors gets a ROLLBACK, so a Stop that lands on it never leaves the driver's own block open. Round trips per SELECT: traced 6 -> 2, untraced 5 -> 2, inside a transaction 5 -> 2.
  • PostgreSQL editor, found in review (on main too): a Stop before the FETCH inside the user's transaction left tablepro_cursor open, so the next SELECT failed with 42P03 and aborted the transaction. The cursor's savepoint is now rolled back, which closes it.
  • RS-02, PostgreSQL pool: deadpool-postgres Fast recycling (its documented default, Client::is_closed()) plus the server check only for a connection idle past the keepalive idle time (30 s). Idle time is read on the wall clock as well, since deadpool's Instant stops while the machine sleeps. A pooled read 2 -> 1 round trip. The cost: a connection a route drops while the machine is awake, within 30 s of its last use, fails one read and leaves the pool.
  • PostgreSQL health probe: a pooled member that fails SELECT 1 leaves the pool, and a login of its own decides whether the route is lost, so one stale member no longer marks the whole connection lost. MySQL keeps its ping (sqlx has no local closed signal, so the ping is what finds a server-closed connection) and SQL Server keeps @@TRANCOUNT (it guards transaction state, not only liveness).
  • RS-03, MySQL: the catalog's fixed statements stay prepared on pool connections (cache of 32), so a catalog read is ping + EXECUTE: 3 -> 2 round trips. Editor and control sessions keep no cache, and a prepare made only for its columns (an empty page, a stream read) leaves the cache, so columns never come from before a schema change. Browse pages still PREPARE, EXECUTE and CLOSE: the text protocol prints FLOAT with fewer digits than the binary one, and LIMIT/OFFSET are inlined by the shared dialect, so each page is a new statement.
  • RS-04, Linux grid: Delete of many drafts removes them in one pass over drafts, edits and the undo history (was one IndexMap shift and one history scan per draft).
  • RS-05, Linux grid: highlight rules run once per row and draw state, cached on the row, keyed by its revision, the compiled rules and a tracker version; operands fold once when the rules compile.
  • RS-06, Linux grid: a cell draw borrows the row key instead of cloning it for each tracker lookup, and skips the lookups when the tracker holds nothing.
  • RS-07, FFI runtime (Windows app): worker threads 12 -> 4 on a 12-core machine, the Linux app's clamp of 2 to 4, now in one place (tablepro_session::runtime::worker_count).

Test plan

  • New: wire_round_trips in the PostgreSQL and MySQL integration suites (fail on main with the counts above), a_stop_before_the_fetch_in_a_transaction_leaves_no_cursor_behind (42P03 on main), an_empty_page_shows_the_columns_after_a_type_change, the_runtime_keeps_the_worker_count_of_a_database_client (12 on main), deleting_the_largest_paste_takes_one_pass_and_its_undo_entry, a_row_works_out_its_highlight_once_for_all_of_its_cells, an_edit_to_the_rule_column_recolours_the_other_cells_of_its_row, a_tracker_change_no_row_was_redrawn_for_reaches_the_next_draw.
  • PostgreSQL and MySQL/MariaDB driver suites with Docker on macOS: all pass except the macOS-only cases that fail on main too (/proc memory peak, the local socket container, macOS TLS verifier wording).
  • Linux app: clippy with and without default features on macOS against Homebrew GTK; the app's tests run in CI.

@datlechin
datlechin enabled auto-merge (squash) November 12, 2026 05:28
@datlechin
datlechin merged commit 67a00a7 into main Nov 12, 2026
46 checks passed
@datlechin
datlechin deleted the fix/perf-rust-core-linux branch November 12, 2026 08:29
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.

1 participant