chore: restructure ~/.ocas layout — nodes/ subdirectory + optional prefix bucketing #84

Closed
opened 2026-06-06 22:27:47 +00:00 by xiaoju · 0 comments
Owner

现状

~/.ocas/ 目录下 CAS 节点文件(<HASH>.bin)与 _index/vars/ 平铺在一起:

~/.ocas/
├── 00F05H2BWY594.bin    # 283 个节点文件平铺
├── ...
├── _index/              # type index
└── vars/                # variables.db

问题:

  • ls ~/.ocas/ 一屏刷不完
  • 节点和元数据(_index、vars)混在一起,语义不清
  • 量大后文件系统性能下降(ext4 单目录数万文件退化)

方案

Phase 1:nodes/ 子目录

~/.ocas/
├── nodes/               # CAS 节点文件
│   ├── <HASH>.bin
│   └── ...
├── _index/
└── vars/
  • FsStore 的节点读写路径从 dir/<HASH>.bin 改为 dir/nodes/<HASH>.bin
  • 兼容迁移:首次 openStore 检测到旧布局(根目录有 .bin 文件)自动迁移

Phase 2(可选):前缀分桶

nodes/
├── 00/
│   ├── 00F05H2BWY594.bin
│   └── ...
├── 01/
│   └── ...

用 hash 前 2 字符分桶,32×32 = 1024 个桶。是否需要取决于节点规模——几百个不需要,上万个值得做。

关联

  • #83 (export/import bundle) — bundle 格式已决定用 nodes/ 子目录
## 现状 `~/.ocas/` 目录下 CAS 节点文件(`<HASH>.bin`)与 `_index/`、`vars/` 平铺在一起: ``` ~/.ocas/ ├── 00F05H2BWY594.bin # 283 个节点文件平铺 ├── ... ├── _index/ # type index └── vars/ # variables.db ``` 问题: - `ls ~/.ocas/` 一屏刷不完 - 节点和元数据(_index、vars)混在一起,语义不清 - 量大后文件系统性能下降(ext4 单目录数万文件退化) ## 方案 ### Phase 1:`nodes/` 子目录 ``` ~/.ocas/ ├── nodes/ # CAS 节点文件 │ ├── <HASH>.bin │ └── ... ├── _index/ └── vars/ ``` - FsStore 的节点读写路径从 `dir/<HASH>.bin` 改为 `dir/nodes/<HASH>.bin` - 兼容迁移:首次 openStore 检测到旧布局(根目录有 .bin 文件)自动迁移 ### Phase 2(可选):前缀分桶 ``` nodes/ ├── 00/ │ ├── 00F05H2BWY594.bin │ └── ... ├── 01/ │ └── ... ``` 用 hash 前 2 字符分桶,32×32 = 1024 个桶。是否需要取决于节点规模——几百个不需要,上万个值得做。 ## 关联 - #83 (export/import bundle) — bundle 格式已决定用 `nodes/` 子目录
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shazhou/ocas#84