mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-18 18:02:08 +08:00
* perf(enhance): cache chain items by file identity Every config generation re-read and re-parsed all seven chain files. Cache the parsed ChainItem keyed by (path, mtime, length) and clone on hit: measured 486us -> 20us per generation (-95.9%) on a seven-file chain set (merge/script/rules fixtures). Profile saves go through tmp+rename so mtime always changes. * perf(config): guard runtime yaml re-serialization runtime_config_yaml re-serialized the multi-megabyte runtime Mapping on every call even when unchanged. Hash the Mapping tree (Value: Hash) and return the cached Arc<String> handle on hit: 4.10ms -> ~0.39ms (hash 290us, ~-90%) for a 3000-node config on the unchanged path, and the handle keeps both hit and miss at a refcount clone instead of copying the yaml body. The 64-bit SipHash key is sound here: a birthday collision needs ~2^32 distinct config states at a volume of a few hundred generations per day, and a colliding pair only serves one stale yaml until the next config change re-hashes. * build(deps): bump tauri-plugin-mihomo to 0.7.1 Pins the revision that derives Clone on ProxyType and DelayHistory, which the upcoming proxy-view cache needs to return cached views without changing the IPC contract. * refactor(backend): right-size the new caches' storage The chain cache never shares its stored ChainItem -- every hit deep-clones it -- so its Arc wrapper only added indirection; store it directly and const-shape it behind a LazyLock static instead of a OnceLock accessor. The yaml cache keeps Arc<String> because callers receive the stored handle, making hit and miss clones O(1). * style(config): hoist the runtime yaml cache to module scope Match the module-level placement of the chain cache and the other named statics; the closure-local declaration shadowed nothing but read worse and forced rustfmt to split the line.