fix: reduce CPU spikes and freeze risk after query execution#54
Merged
Conversation
- autocomplete: add liveness guard in extract_projection_columns so a token slice with an unbalanced inner paren can't park `i` forever. - datasource: Cell::display returns Cow<'_, str>; large Text/Decimal cells now borrow instead of cloning on every render frame. - action: coalesce DDL-triggered schema reloads — back-to-back DDLs no longer queue redundant full reintrospections. Bumps the patch version to 0.16.2.
The Table widget and `distribute_columns` were both feeding the kasuari constraint solver `[Constraint::Min(8); n]` — identical strengths and coefficients, which is the exact degenerate-pivot input that triggers kasuari issue #18 (the solver loops forever in the simplex pivot path). lldb on a frozen rowdy backtraced to `kasuari::row::Row::insert_symbol`, confirming the hang. Switch to hand-computed `Constraint::Length` widths — even split of the inner width with the remainder spread across the leading columns, matching the layout the solver had been producing. Same math is reused for the hit-testing column-X table, so mouse clicks still land on the right column. Ref: ratatui/kasuari#18
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.
Summary
Investigated reports of the TUI freezing with 100% CPU right after a query completes. lldb backtrace pinpointed the hang at
kasuari::row::Row::insert_symbol— a known issue in the Cassowary solver ratatui 0.30 uses forLayout::split. See ratatui/kasuari#18: the simplex pivots cycle on degenerate ties when fed many identicalConstraint::Min(_)constraints. Our result-table column widths were exactly that input.Fixes
src/ui/results_view.rs) — primary fix. Replace[Constraint::Min(8); n]with hand-computedConstraint::Length(w)widths that even-split the inner width.distribute_columnsnow does the same arithmetic directly instead of callingLayout::horizontal(...).split(...). Same output shape; existing layout tests still pass. The kasuari solver no longer runs on the per-frame result render.src/app.rs,src/action/mod.rs) — addedApp::schema_reload_in_flight. Back-to-back DDLs no longer queue duplicate full-schema reintrospections; the flag clears onCacheStage::Reloadedand onConnected.src/datasource/cell.rs+ callers) —Cell::display()now returnsCow<'_, str>.Text/Decimal/Other { repr }borrow their existingStringinstead of cloning per visible cell per frame. ratatui clips to column width at draw time, so we no longer allocate megabytes per redraw for wide JSON/TEXT values.src/autocomplete/context.rs) —extract_projection_columnscould re-enter its outer loop withoutiadvancing if the inner scan hit an unbalanced inner)at depth 0. Added a liveness guard so the worst case is a dropped projection, never a hang.Bumps the patch version to 0.16.2.
Test plan
cargo checkcleancargo test --bin rowdy— 575 passedWITH cte AS (SELECT ... FROM t)body