Skip to content

Commit 3d96111

Browse files
authored
Revert "perf(plugins): extend discovery threading to loader, manifest registr…" (#84278)
This reverts commit f5f0b2c.
1 parent f5f0b2c commit 3d96111

6 files changed

Lines changed: 24 additions & 132 deletions

src/plugins/config-contracts.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { OpenClawConfig } from "../config/types.openclaw.js";
22
import { isRecord } from "../utils.js";
3-
import { discoverOpenClawPlugins, type PluginDiscoveryResult } from "./discovery.js";
3+
import { discoverOpenClawPlugins } from "./discovery.js";
44
import { loadPluginManifestRegistry } from "./manifest-registry.js";
55
import type { PluginManifestConfigContracts } from "./manifest.js";
66
import type { PluginOrigin } from "./plugin-origin.types.js";
@@ -114,13 +114,6 @@ export function resolvePluginConfigContractsById(params: {
114114
fallbackToBundledMetadataForResolvedBundled?: boolean;
115115
fallbackBundledPluginIds?: readonly string[];
116116
pluginIds: readonly string[];
117-
/**
118-
* Pre-computed discovery result. When supplied, the bundled-fallback path
119-
* skips its internal `discoverOpenClawPlugins` call so callers sharing a
120-
* discovery snapshot across registry helpers avoid redundant filesystem
121-
* walks.
122-
*/
123-
discovery?: PluginDiscoveryResult;
124117
}): ReadonlyMap<string, PluginConfigContractMetadata> {
125118
const matches = new Map<string, PluginConfigContractMetadata>();
126119
const pluginIds = [
@@ -139,12 +132,10 @@ export function resolvePluginConfigContractsById(params: {
139132
if (bundledContractFallbacks.has(pluginId)) {
140133
return bundledContractFallbacks.get(pluginId);
141134
}
142-
const discovery =
143-
params.discovery ??
144-
discoverOpenClawPlugins({
145-
workspaceDir: params.workspaceDir,
146-
env: params.env,
147-
});
135+
const discovery = discoverOpenClawPlugins({
136+
workspaceDir: params.workspaceDir,
137+
env: params.env,
138+
});
148139
const registry = loadPluginManifestRegistry({
149140
config: params.config,
150141
workspaceDir: params.workspaceDir,

src/plugins/discovery-threading.test.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.

src/plugins/installed-plugin-index-registry.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ export function resolveInstalledPluginIndexRegistry(params: LoadInstalledPluginI
2525
const normalized = normalizePluginsConfig(params.config?.plugins);
2626
const installRecords =
2727
params.installRecords ?? loadInstalledPluginIndexInstallRecordsSync({ env: params.env });
28-
const discovery =
29-
params.discovery ??
30-
discoverOpenClawPlugins({
31-
workspaceDir: params.workspaceDir,
32-
extraPaths: normalized.loadPaths,
33-
env: params.env,
34-
installRecords,
35-
});
28+
const discovery = discoverOpenClawPlugins({
29+
workspaceDir: params.workspaceDir,
30+
extraPaths: normalized.loadPaths,
31+
env: params.env,
32+
installRecords,
33+
});
3634
return {
3735
candidates: discovery.candidates,
3836
registry: loadPluginManifestRegistry({

src/plugins/installed-plugin-index-types.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { OpenClawConfig } from "../config/types.js";
22
import type { PluginInstallRecord } from "../config/types.plugins.js";
33
import type { PluginCompatCode } from "./compat/registry.js";
4-
import type { PluginCandidate, PluginDiscoveryResult } from "./discovery.js";
4+
import type { PluginCandidate } from "./discovery.js";
55
import type { PluginInstallSourceInfo } from "./install-source-info.js";
66
import type { InstalledPluginFileSignature } from "./installed-plugin-index-hash.js";
77
import type { PluginManifestRecord } from "./manifest-registry.js";
@@ -130,13 +130,6 @@ export type LoadInstalledPluginIndexParams = {
130130
installRecords?: Record<string, PluginInstallRecord>;
131131
candidates?: PluginCandidate[];
132132
diagnostics?: PluginDiagnostic[];
133-
/**
134-
* Pre-computed discovery result. When supplied (and `candidates` is not),
135-
* the internal `discoverOpenClawPlugins` call is skipped. Callers sharing a
136-
* discovery snapshot across registry helpers in the same flow should supply
137-
* this to avoid redundant filesystem walks.
138-
*/
139-
discovery?: PluginDiscoveryResult;
140133
now?: () => Date;
141134
};
142135

src/plugins/loader.ts

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ import {
5050
type NormalizedPluginsConfig,
5151
} from "./config-state.js";
5252
import { isPluginEnabledByDefaultForPlatform } from "./default-enablement.js";
53-
import {
54-
discoverOpenClawPlugins,
55-
type PluginCandidate,
56-
type PluginDiscoveryResult,
57-
} from "./discovery.js";
53+
import { discoverOpenClawPlugins, type PluginCandidate } from "./discovery.js";
5854
import { shouldRejectHardlinkedPluginFiles } from "./hardlink-policy.js";
5955
import { getGlobalHookRunner, initializeGlobalHookRunner } from "./hook-runner-global.js";
6056
import { toSafeImportPath } from "./import-specifier.js";
@@ -202,14 +198,6 @@ export type PluginLoadOptions = {
202198
loadModules?: boolean;
203199
throwOnLoadError?: boolean;
204200
manifestRegistry?: PluginManifestRegistry;
205-
/**
206-
* Pre-computed plugin discovery result. When supplied, internal calls to
207-
* `discoverOpenClawPlugins` are skipped. Callers in the same startup flow
208-
* can compute one discovery result and share it across loader entry points
209-
* to eliminate redundant filesystem walks. Ignored when `manifestRegistry`
210-
* is also provided (the registry already implies a discovery snapshot).
211-
*/
212-
discovery?: PluginDiscoveryResult;
213201
};
214202

215203
function detailPluginStartupTrace(
@@ -1702,13 +1690,12 @@ export function loadOpenClawPlugins(options: PluginLoadOptions = {}): PluginRegi
17021690
candidates: createPluginCandidatesFromManifestRegistry(suppliedManifestRegistry),
17031691
diagnostics: [] as PluginDiagnostic[],
17041692
}
1705-
: (options.discovery ??
1706-
discoverOpenClawPlugins({
1693+
: discoverOpenClawPlugins({
17071694
workspaceDir: options.workspaceDir,
17081695
extraPaths: normalized.loadPaths,
17091696
env,
17101697
installRecords,
1711-
}));
1698+
});
17121699
const manifestRegistry =
17131700
suppliedManifestRegistry ??
17141701
loadPluginManifestRegistry({
@@ -2572,14 +2559,12 @@ export async function loadOpenClawPluginCliRegistry(
25722559
activateGlobalSideEffects: false,
25732560
});
25742561

2575-
const discovery =
2576-
options.discovery ??
2577-
discoverOpenClawPlugins({
2578-
workspaceDir: options.workspaceDir,
2579-
extraPaths: normalized.loadPaths,
2580-
env,
2581-
installRecords,
2582-
});
2562+
const discovery = discoverOpenClawPlugins({
2563+
workspaceDir: options.workspaceDir,
2564+
extraPaths: normalized.loadPaths,
2565+
env,
2566+
installRecords,
2567+
});
25832568
const manifestRegistry = loadPluginManifestRegistry({
25842569
config: cfg,
25852570
workspaceDir: options.workspaceDir,

src/plugins/manifest-registry.ts

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,7 @@ import { resolveUserPath } from "../utils.js";
1010
import { resolveCompatibilityHostVersion } from "../version.js";
1111
import { loadBundleManifest } from "./bundle-manifest.js";
1212
import { normalizePluginsConfigWithResolver } from "./config-policy.js";
13-
import {
14-
discoverOpenClawPlugins,
15-
type PluginCandidate,
16-
type PluginDiscoveryResult,
17-
} from "./discovery.js";
13+
import { discoverOpenClawPlugins, type PluginCandidate } from "./discovery.js";
1814
import { shouldRejectHardlinkedPluginFiles } from "./hardlink-policy.js";
1915
import { loadInstalledPluginIndexInstallRecordsSync } from "./installed-plugin-index-record-reader.js";
2016
import type { PluginManifestCommandAlias } from "./manifest-command-aliases.js";
@@ -920,13 +916,6 @@ export function loadPluginManifestRegistry(
920916
diagnostics?: PluginDiagnostic[];
921917
installRecords?: Record<string, PluginInstallRecord>;
922918
bundledChannelConfigCollector?: BundledChannelConfigCollector;
923-
/**
924-
* Pre-computed discovery result. When supplied (and `candidates` is not),
925-
* the internal `discoverOpenClawPlugins` call is skipped. Callers sharing
926-
* a discovery snapshot across multiple registry helpers in the same flow
927-
* should supply this to avoid redundant filesystem walks.
928-
*/
929-
discovery?: PluginDiscoveryResult;
930919
} = {},
931920
): PluginManifestRegistry {
932921
const config = params.config ?? {};
@@ -947,13 +936,12 @@ export function loadPluginManifestRegistry(
947936
candidates: params.candidates,
948937
diagnostics: params.diagnostics ?? [],
949938
}
950-
: (params.discovery ??
951-
discoverOpenClawPlugins({
939+
: discoverOpenClawPlugins({
952940
workspaceDir: params.workspaceDir,
953941
extraPaths: normalized.loadPaths,
954942
env,
955943
installRecords: getInstallRecords(),
956-
}));
944+
});
957945
const diagnostics: PluginDiagnostic[] = [...discovery.diagnostics];
958946
const candidates: PluginCandidate[] = discovery.candidates;
959947
const records: PluginManifestRecord[] = [];

0 commit comments

Comments
 (0)