防锈重性能
- 作者仓库星标 0
- 作者仓库 skills-registry
- 领域
- 通用
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @tomevault-io · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部接口密钥
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 运行环境要求
- 未检出明确要求
- 检测到的文件与系统行为
-
- 只读
- 命令执行
- 网络行为
- 仅限本地
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# Rust-Heavy Performance
Use this skill when a feature can become slow or memory-heavy. Prefer implementing heavy paths in `src-tauri/` and keep the frontend thin.
## Core rule
- If work is CPU-heavy, row-heavy, or repeatedly recomputed, do it in Rust.
- JavaScript/React should orchestrate UI state and rendering, not run bulk processing loops.
## Rust-first implementation pattern
1. Add or extend an async command in `src-tauri/src/commands.rs`.
2. Keep query execution and pooling logic in `src-tauri/src/db.rs` and related Rust modules.
3. Return a compact DTO to the frontend (already shaped for display).
4. Call it from `src/data/repositories/` using existing `invoke` patterns.
5. Render in feature UI with virtualization for large result sets.
## Memory efficiency guardrails
- Use bounded reads (`LIMIT`, pagination, or chunked iteration), never unbounded materialization.
- Avoid cloning large vectors/strings when references or incremental building is enough.
- Prefer streaming/chunked processing over collecting everything at once.
- Keep structs narrow for IPC responses; do not ship unused fields.
- Reuse pooled database connections; avoid ad hoc new clients per action.
## Speed guardrails
- Push filtering, sorting, grouping, and aggregation down to SQL/Rust.
- Minimize Rust<->webview payload size; serialize only what UI needs now.
- Cache or memoize expensive Rust-side intermediate results only when reuse is likely and bounded.
- Use async command handlers; avoid blocking I/O in command paths.
## Easy-to-implement defaults
- Start from existing command and repository patterns instead of inventing new data paths.
- Keep each command focused: one clear job, typed input, typed output.
- Introduce feature flags/options only after proving a real need.
- Keep frontend changes small: trigger command, handle loading/error, display bounded data.
## Anti-patterns to avoid
- Doing large data transforms in React `useMemo` or `useEffect`.
- Returning huge raw row sets to the UI and shaping them in JavaScript.
- Recomputing heavy derived data on every render or keystroke.
- Mixing unrelated concerns into a single Rust command handler.
## Review checklist
- Is the heavy work in Rust instead of JavaScript?
- Are reads and payloads explicitly bounded?
- Is memory growth controlled for worst-case input size?
- Is command/repository wiring following existing VeloxDB patterns?
- Does the UI virtualize large lists/tables and avoid unnecessary recomputation?
---
> Source: [abeni16/veloxdb](https://github.com/abeni16/veloxdb) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-23 -->
章节与文件索引
按说明文件中的顺序排列。
核心规则
Rust 优先实现模式
内存效率护栏
速度护栏
易于实现的默认值
文件/命令 -> src-tauri/ · src-tauri/src/commands.rs · src-tauri/src/db.rs · src/data/repositories/ · invoke · LIMIT · useMemo · useEffect
内容校验值 -> 1b0de4f9a619
当前原文的自动摘译,尚未人工审校。
核心规则
如果工作是 CPU 密集型、行密集型或重复重新计算,请在 Rust 中完成。 JavaScript/React 应该协调 UI 状态和渲染,而不是运行批量处理循环。
Rust 优先实现模式
在
src-tauri/src/commands.rs中添加或扩展异步命令。将查询执行和池逻辑保留在src-tauri/src/db.rs和相关的 Rust 模块中。将紧凑的 DTO 返回到前端(已经成形以供显示)。使用现有的invoke模式从src/data/repositories/调用它。通过虚拟化功能在功能 UI 中呈现大型结果集。内存效率护栏
使用有界读取(
LIMIT、分页或分块迭代),切勿使用无界物化。当引用或增量构建足够时,避免克隆大型向量/字符串。更喜欢流式/分块处理而不是一次性收集所有内容。保持 IPC 响应的结构狭窄;不要运送未使用的字段。重用池化数据库连接;避免每次操作都临时出现新客户。速度护栏
将过滤、排序、分组和聚合推送到 SQL/Rust。最小化 Rust<->webview 负载大小;仅序列化 UI 现在需要的内容。仅当重用可能且有限时才缓存或记忆昂贵的 Rust 端中间结果。使用异步命令处理程序;避免在命令路径中阻塞 I/O。
易于实现的默认值
从现有命令和存储库模式开始,而不是发明新的数据路径。保持每个命令的重点:一项明确的工作、键入的输入、键入的输出。仅在证明确实需要后才引入功能标志/选项。保持前端变化较小:触发命令、处理加载/错误、显示有界数据。