perf(plugins): defer bundle.load() until first connection or format use#1024
Merged
perf(plugins): defer bundle.load() until first connection or format use#1024
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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
vmmap); footprint 47.9 MB (PR A baseline) → 44.9 MBbundle.load()). The bundle's executable code is loaded on demand when a connection of that driver type is opened, an export format is invoked, or an import format is invokeddlopen,NSBundleLoad)" at launch. Apple's NSBundle API is designed for this:Bundle(url:)reads metadata,bundle.load()is the explicit gate,bundle.isLoadedis queryable.mdimporter,.qlgenerator,.appex): host reads each bundle's Info.plist at registration time and loads code only when the system invokes the pluginChanges
PluginManifest.swift(new) — readsTableProProvidesDatabaseTypeIds/TableProProvidesExportFormatIds/TableProProvidesImportFormatIdsfrom a bundle's Info.plist without loading codeTableProProvides*manifest keys (MySQL, PostgreSQL, SQLite, Redis, ClickHouse, SQL/CSV/JSON/XLSX/MQL exports, SQL import)PluginManager—loadPlugins()splits pending URLs into lazy (manifest-bearing) and eager (legacy) buckets. Lazy ones go through the newregisterLazyManifest(_:url:source:manifest:)which builds aPluginEntryfrom manifest + the existingPluginMetadataRegistrydefaults, with nobundle.load(). NewactivateDriver(databaseTypeId:),activateExportFormat(_:),activateImportFormat(_:)methods load the bundle and run the existingregisterCapabilitiespath on first use. Plugins without manifest keys keep the eager path (backwards compat for separately-distributed plugins)PluginManager+Registration—driverPlugin(for:),exportPlugin(forFormat:),importPlugin(forFormat:)accessors auto-activate. NewallExportPlugins()/allImportPlugins()activate all lazy entries before returning the full list (used by Export/Import dialogs that need to enumerate available formats)PluginManager+Validation—validateDependencies()skipsbundle.principalClassaccess for unloaded bundles viabundle.isLoadedguard (without this, dep validation force-loads every plugin)DatabaseDriver—DatabaseDriverFactory.createDriver(for:)usesPluginManager.shared.driverPlugin(for:)instead of direct dict access, picking up auto-activationPluginManager.shared.exportPlugins[id]/importPlugins[id]direct dict access to the activating accessors (exportPlugin(forFormat:),importPlugin(forFormat:)).ExportDialog/ImportDialoguseallExportPlugins()/allImportPlugins()to populate format pickersBackwards compatibility
Plugins without
TableProProvides*keys (any user-installed plugin from the registry that hasn't been re-released) keep working unchanged via the eagerbundle.load()path. NoTableProPluginKitVersionbump is needed since the protocol contract didn't change.Test plan
vmmap | grep tableplugin).tablepluginon Finder: install path still works