mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-18 01:42:10 +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 string on hit: 4.10ms -> ~0.39ms (hash 290us plus one Arc string copy, ~-90%) for a 3000-node config on the unchanged path. 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): drop dead Arc wrappers from the new caches Neither cache ever shares its stored value: every hit deep-clones, so the Arc layers only added indirection and one extra allocation on the yaml miss path. Store ChainItem and String directly and const-shape the chain cache behind a LazyLock static instead of a OnceLock accessor. * 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.