Skip to content

Commit 8eb9d81

Browse files
authored
wasm: optimize lookup in control plane (#57901)
In a real world environment with many WasmPlugins, we saw about 10% of CPU usage on the lookup MatchListener. 1/3 of these is spent on HTTP lookups, while 2/3 on TCP lookups. However, the cluster only has HTTP wasm plugins. By flipping the condition to filter by the fast check (MatchType) we can avoid the expensive MatchListener calls.
1 parent 1dd3e10 commit 8eb9d81

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pilot/pkg/model/push_context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2204,7 +2204,7 @@ func (ps *PushContext) WasmPluginsByListenerInfo(proxy *Proxy, info WasmPluginLi
22042204
for _, ns := range slices.FilterDuplicates(lookupInNamespaces) {
22052205
if wasmPlugins, ok := ps.wasmPluginsByNamespace[ns]; ok {
22062206
for _, plugin := range wasmPlugins {
2207-
if plugin.MatchListener(selectionOpts, info) && plugin.MatchType(pluginType) {
2207+
if plugin.MatchType(pluginType) && plugin.MatchListener(selectionOpts, info) {
22082208
matchedPlugins[plugin.Phase] = append(matchedPlugins[plugin.Phase], plugin)
22092209
}
22102210
}

0 commit comments

Comments
 (0)