Problem
The Try! macro in CreateEffectForRequest::Fn calls Parameters.clone() unconditionally on every module invocation, even when that module does not handle the method. With 27 modules in the chain, a FileSystem.ReadFile call (the most frequent RPC in any session) clones Parameters 5 times before reaching its handler and discards all 5 clones. A $tree:register call clones it 14 times.
serde_json::Value clone is not free — it recursively copies the full JSON tree including heap-allocated strings and maps.
File: Source/Track/Effect/CreateEffectForRequest/mod.rs
Root Cause
macro_rules! Try {
($Module:ident) => {
// Parameters.clone() called even when this module doesn't handle MethodName
if let Some(Result) = $Module::CreateEffect::<R>(MethodName, Parameters.clone()) {
return Result;
}
};
}
Fix
- Add a
Matches(method: &str) -> bool function to each domain module (a simple match on &str returning bool — Rust compiles this to a jump table at zero cost).
- Refactor
Try! to call Matches first, then pass owned Parameters only to the matched module's CreateEffect.
- Reorder the
Try! chain to reflect actual call frequency: FileSystem → Configuration → TreeView → Commands → Terminal → rest.
macro_rules! Try {
($Module:ident) => {
if $Module::Matches(MethodName) {
return $Module::CreateEffect::<R>(MethodName, Parameters);
}
};
}
Additional Scope for Same PR
- Audit
FileReadAlias.rs — confirm it does not duplicate logic already in FileSystem.rs; fold aliases into FileSystem::Matches if so.
- Add a comment to
Utilities/Params.rs noting that str_at / bool_at should be replaced by a ParsedParams wrapper parsed once at the DispatchSideCarRequest boundary (log as a separate follow-up issue).
Problem
The
Try!macro inCreateEffectForRequest::FncallsParameters.clone()unconditionally on every module invocation, even when that module does not handle the method. With 27 modules in the chain, aFileSystem.ReadFilecall (the most frequent RPC in any session) clonesParameters5 times before reaching its handler and discards all 5 clones. A$tree:registercall clones it 14 times.serde_json::Valueclone is not free — it recursively copies the full JSON tree including heap-allocated strings and maps.File:
Source/Track/Effect/CreateEffectForRequest/mod.rsRoot Cause
Fix
Matches(method: &str) -> boolfunction to each domain module (a simplematchon&strreturningbool— Rust compiles this to a jump table at zero cost).Try!to callMatchesfirst, then pass ownedParametersonly to the matched module'sCreateEffect.Try!chain to reflect actual call frequency:FileSystem → Configuration → TreeView → Commands → Terminal → rest.Additional Scope for Same PR
FileReadAlias.rs— confirm it does not duplicate logic already inFileSystem.rs; fold aliases intoFileSystem::Matchesif so.Utilities/Params.rsnoting thatstr_at/bool_atshould be replaced by aParsedParamswrapper parsed once at theDispatchSideCarRequestboundary (log as a separate follow-up issue).