Repository navigation
perf(results): run the adapter's side of every driver call off the main actor - #4595
Merged
Merged
Conversation
…in actor Under NonisolatedNonsendingByDefault the adapter's async entry points ran on their caller's actor, the main one, so the statement checks, the statement's description and the mapping of each answer ran there. They are @Concurrent now, and the [Any?] entry points convert their parameters first. QueryExecutor's fetches are @Concurrent too. The driver call itself already left: PluginKit builds without the feature.
datlechin
enabled auto-merge (squash)
November 26, 2026 01:51
…DriverAdapter Maintenance, object comments, materialized views, table options, sequences and view templates move to PluginDriverAdapter+ObjectEditing.swift, and the transaction calls to PluginDriverAdapter+Transactions.swift. Behavior and access are unchanged. This brings the class body and the file back under the SwiftLint type_body_length and file_length limits.
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
PluginDriverAdapter's async entry points are@concurrent, so the adapter's own work around a driver call leaves the main actor: the statement checks inadmit(the NUL scan and the database-move classifier, both linear in the text), the statement's lexical description,readSchema, and the mapping of the answer (mapQueryResult,fetchAllColumnsandfetchAllForeignKeysover a whole schema, routines and types sorted).[Any?]entry points (executeUserQuery,executeParameterized,executeBatch) convert their parameters on the caller's actor, since[Any?]is not Sendable, and hand the Sendable values to a private@concurrentbody that does the rest.QueryExecutor.fetchBoundedQueryData,fetchExplainPlanandfetchQueryDataare@concurrent, and the comment that called them background work without it is gone.fetchQueryDataParameterizedstays on its caller: its[Any?]cannot cross, and its driver call leaves at the adapter.What the measurement showed: the driver call itself already ran off the main thread.
TableProPluginKitis the one target built withoutSWIFT_APPROACHABLE_CONCURRENCY, so eachPluginDatabaseDriverrequirement keeps the oldnonisolated asyncmeaning and hops to the global executor; the plugin's own work after anawait(MongoDB's flatten, ClickHouse's classify,PluginBoundedStream.collect) runs there. What stayed on main was the adapter's side of each call.Test plan
PluginDriverAdapterIsolationTests(new): a stub driver records whether the adapter read its state, and whether its own calls ran, on the main thread, for a user query, a parameterized one, a bounded read throughPluginBoundedStream.collect,QueryExecutor.fetchQueryDataand a catalog read, each called from a@MainActortest. On main the adapter's reads happen on the main thread and every case fails; here all five pass. The driver's own calls are off the main thread on both.verify.sh test PluginDriverAdapterIsolationTests PluginDriverAdapterConcurrencyTests PluginDriverAdapterParameterTests PluginDriverAdapterStatementContextTests PluginRowLocatorTests ApprovedTargetTests.Closes #4530