Repository navigation
perf(memory): build each result row at its exact size in every driver - #4563
Merged
Merged
Conversation
On the macOS 13 and iOS 18 deployment targets an enumerated sequence is not a Collection, so `enumerated().map` cannot reserve its count and grows the row by doubling: a 20-cell row ends at capacity 36, 896 bytes instead of 512. Map over `indices` in every per-row builder: PostgreSQL single-row reads, MongoDB flattening, ClickHouse TabSeparated rows and the binary demote pass, Snowflake, BigQuery, the core result stream and the iOS plugin row emitters.
datlechin
enabled auto-merge (squash)
November 26, 2026 01:50
# Conflicts: # apple/Packages/TableProCore/Tests/TableProPluginKitTests/ClickHouseTabSeparatedRowDecoderTests.swift # apple/Plugins/TableProPluginKit/ClickHouseTabSeparatedRowDecoder.swift
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
EnumeratedSequenceis only aSequence(itsCollectionconformance needs the OS 26 standard library), sox.enumerated().mapcannot reserve its count and grows each row by doubling.indices, which allocates exactlycount: PostgreSQL single-row reads (table pages, Fetch All, bounded reads), MongoDB flattening, ClickHouse TabSeparated rows and the binary-column demote pass, Snowflake and BigQuery rows, the coreQueryResultStreamingrows, and the two iOS plugin row emitters (PluginBackedDriver,PluginGridValue).Measured
-target arm64-apple-macosx13.0: a 20-cell row fromenumerated().maphas capacity 36 andmalloc_size896 B; fromindices.map, capacity 20 and 512 B. Built for macOS 26, both give 20 and 512 B, which is why a scratch test on a current target sees no waste.trips_1m. The phys_footprint run with the app was not repeated here.Test plan
capacity == count:LibPQSingleRowCapacityTests(a client-builtPGresult),ClickHouseTabSeparatedRowDecoderTests,ClickHouseResponseClassifierTests(demote path),QueryResultStreamingTests, andMongoDBPluginConnectionTestson iOS.swift test --filter ExactCapacity: 3 executed, 3 failed); with the change they pass (3 of 3). The iOS test runs on CI only, since this Mac has no simulator runtime.verify.sh buildandverify.sh pluginspass; Snowflake, BigQuery and MongoDB are registry plugins with no macOS test target.verify.sh --jobs 4buildPASS,pluginsPASS,testoverLibPQSingleRowCapacityTests,LibPQSingleRowReadTests,ClickHouseTabSeparatedRowDecoderTests,ClickHouseResponseClassifierTestsandQueryResultStreamingTestsPASS: 7 executed in the Unit plan and 60 underswift test, none failed.build-for-testingofTableProMobilefor the generic simulator succeeds, soMongoDBPluginConnectionTestscompiles. This Mac has no simulator runtime, so the iOS suite itself runs on CI only. The earlier rediOS and Package Testsnever ran: it was cancelled after 24 hours in the queue.Closes #4520