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

Open
#519 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
c

Research direction

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.

Written by the indexing model from the issue text.

Description

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.


Dominant language
C
Stars
287
Forks
33
Avg merge
2d 17h
Merged PRs (30d)
18

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sysprog21/elfuse

All issues in sysprog21/elfuse

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.