FUSE sessions reserve ~158 KiB of fixed tables each, mostly unused

未关闭
#519 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
活跃
技术栈
c

调研方向

Start with src/syscall/fuse.c, especially fuse_session_t, fuse_proc_open, and the node-ref path functions named in the issue; trace how requests and node references are allocated and released. Compare the two proposed approaches and check existing limits such as FUSE_MAX_OPEN_FILES and FUSE_MAX_SESSIONS. Done means reducing per-session storage and initialization cost while preserving FUSE request and node-reference behavior; the issue names no tests.

由索引模型根据 Issue 内容生成。

描述

enhancement

Each fuse_session_t in src/syscall/fuse.c carries four fixed arrays:

Field Size
requests[FUSE_MAX_PENDING] (128) 14,336 B
node_refs[FUSE_MAX_NODE_REFS] (4096) 98,304 B
node_ref_hash[8192] 32,768 B
node_ref_free[4096] 16,384 B

One session is 162,016 bytes, and fuse_sessions[8] is 1.24 MiB of static storage. fuse_proc_open memsets the whole slot and fills both index tables, so every open("/dev/fuse") makes about 158 KiB resident. The slot stays resident until the /dev/fuse fd and every FUSE file fd are closed, which is usually the daemon's whole lifetime.

Linux keeps the same information but allocates it on demand (torvalds/linux master, fs/fuse):

  • Requests are allocated per request: fuse_request_alloc → kmem_cache_zalloc(fuse_req_cachep, ...) (dev.c). Only background requests are capped, at FUSE_DEFAULT_MAX_BACKGROUND (12).
  • The lookup count is a field of the inode, u64 nlookup in struct fuse_inode (fuse_i.h). It is incremented in fuse_iget, and FORGET is sent from fuse_evict_inode, so there is no per-connection nodeid table.

The node-ref tables are also far larger than elfuse can fill. fuse_walk_path_locked drops each component's lookup as soon as it steps past it. Only fuse_open_path (an open file) and fuse_materialize_path (an exec copy) keep the final lookup. The live count is therefore bounded by FUSE_MAX_OPEN_FILES (128, shared by all sessions) plus the walks in flight, against 4096 entries per session. The comment that sizes the table for ls -R style walks no longer matches the walk.

Possible directions:

  • Size node_refs from FUSE_MAX_OPEN_FILES instead of 4096.
  • Or allocate the node-ref tables and request slots on demand, as Linux does.

Either change also makes it cheaper to raise FUSE_MAX_SESSIONS above 8.


主要语言
C
星标
287
派生
33
平均合并
2 天 17 小时
30 天内合并 PR
18

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

sysprog21/elfuse 的其他 Issue

查看 sysprog21/elfuse 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。