Repository navigation
perf(results): pack typed columns while the driver streams rows (#1552) - #1719
Merged
Merged
Conversation
…nstead of collecting List<List<Object?>> first (#1552)
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.
Closes #1552
PostgreSQL copied every row with
row.toList(), SQLite built a list per row, MySQL kept allResultSetRows and then read each withcolAt;CompactResultDataset.fromRawRowsthen walked the whole list once for the kinds and once per column to pack.ResultColumnsBuilder(core/database/result_columns_builder.dart) takes the rows as they arrive (addRow, oraddCell+endRowfor drivers whose rows are not lists) and learns each column's kind on the way. Rules unchanged: all ints int64, all numbers float64, all strings string, all NULL string, else generic; the first 60 non-null cells still go through the driver formatter (#1548). A column can be demoted late (ints that meet a double, anything that meets a string), so ints and doubles are kept in separate buffers: a column that ends up generic still holds its ints as ints, exactly as before.fromRawRowsnow feeds the builder, so every existing dataset test covers it. MySQL uses a newforEachThenDrain(the drain-after-cap behaviour oftakeThenDrainstays, which is built on it).Tests: kinds and raw values for mixed, late-demoted and all-NULL columns, short rows, cell-by-cell vs whole rows, the formatter case, and 150 random columns checked against the kind rules (some beyond the 256-row first buffer). All of
test/core/database, mysql, postgresql, sqlite and workspace tests pass locally.Measured (JIT test runner, 50k x 20 mixed columns, 3 runs each; rows already in memory as the driver holds them): old path (copy rows, then pack) 124-135 ms, peak RSS over baseline 26-40 MiB; builder 118-121 ms, 21-25 MiB. 5k rows: 16-20 ms vs 17-22 ms, no difference outside noise. So the gain is the intermediate list's memory (about half the peak at 50k) and a small time saving; I did not measure against live servers.