Skip to content

Add syscall tracing to FuseFS#1

Merged
rslota merged 1 commit intomainfrom
rafal.s/revup/main/syscall-tracing
Feb 19, 2026
Merged

Add syscall tracing to FuseFS#1
rslota merged 1 commit intomainfrom
rafal.s/revup/main/syscall-tracing

Conversation

@rslota
Copy link
Copy Markdown

@rslota rslota commented Feb 19, 2026

No description provided.

@rslota
Copy link
Copy Markdown
Author

rslota commented Feb 19, 2026

Reviews in this chain:
#1 Add syscall tracing to FuseFS

@rslota
Copy link
Copy Markdown
Author

rslota commented Feb 19, 2026

# head base diff date summary
0 657659bb 3bdbda5c diff Feb 19 12:01 PM 3 files changed, 285 insertions(+), 22 deletions(-)
1 0af1c438 3bdbda5c diff Feb 19 17:09 PM 1 file changed, 28 insertions(+), 62 deletions(-)

@rslota rslota requested review from balysv, erszcz and kzemek February 19, 2026 11:01
Comment thread src/fuse_fs.rs
_name: &OsStr,
_size: u32,
name: &OsStr,
size: u32,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32 bits for size seems a bit conservative... 4GiB is not that uncommon for file sizes nowadays, though probably would be a problem due to other reasons in the sandbox agent

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's possible to have single syscall with bigger size. I think FUSE is typed for u32 🤔 At least it is in this codebase

Comment thread src/syscall_trace.rs Outdated
SyscallArgs::Lookup {
parent,
name: name.to_string(),
parent_path: parent_path.map(String::from),
Copy link
Copy Markdown

@erszcz erszcz Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably get away without these extra allocations - after all, these strings have to exist somewhere already and we just want to "print" them.


The SyscallArgs variants currently allocate String for every trace event, but the data is already available as borrowed &str:

  • path comes from self.path_for_inode(ino)Option<&str> borrowed from the inode_to_node HashMap
  • name comes from name.to_string_lossy()Cow<'_, str> (zero-copy for valid UTF-8)

Since trace() serializes and sends immediately, the borrows just need to live through that call. Adding a lifetime to the types eliminates all heap allocations:

#[derive(Debug, Serialize)]
pub enum SyscallArgs<'a> {
    Lookup {
        parent: u64,
        name: &'a str,
        #[serde(skip_serializing_if = "Option::is_none")]
        parent_path: Option<&'a str>,
    },
    Getattr {
        ino: u64,
        fh: Option<u64>,
        #[serde(skip_serializing_if = "Option::is_none")]
        path: Option<&'a str>,
    },
    // ... same for all variants
}

#[derive(Debug, Serialize)]
pub struct SyscallEvent<'a> {
    pub syscall: &'static str,
    pub timestamp_ns: u128,
    #[serde(flatten)]
    pub args: SyscallArgs<'a>,
}

Then the convenience methods just pass the borrows through with no .to_string():

pub fn lookup(&self, parent: u64, name: &str, parent_path: Option<&str>) {
    self.trace("lookup", SyscallArgs::Lookup { parent, name, parent_path });
}

Zero heap allocations per trace event. The only allocation is the output JSON buffer in serde_json::to_vec, which is unavoidable.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, i've been living under a rock and never actually seen rust to this day, so a bit of learning like that helps ;)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My pleasure 🎩😁

@rslota rslota force-pushed the rafal.s/revup/main/syscall-tracing branch from 657659b to 0af1c43 Compare February 19, 2026 16:09
@rslota rslota merged commit 427a050 into main Feb 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants