Skip to content

Add renacer tracing integration for syscall-level debugging #89

@noahgift

Description

@noahgift

Feature Request

Integrate with renacer for syscall-level tracing and performance analysis.

What is Renacer?

Renacer is a pure Rust system call tracer with:

  • Full syscall tracing (335 Linux syscalls)
  • DWARF debug info correlation
  • SIMD-accelerated statistics
  • Anomaly detection
  • Flamegraph export

Use Cases

  1. Performance debugging - Why is suggest slow? Trace file I/O, memory allocation
  2. Model loading analysis - Profile model deserialization
  3. I/O bottleneck detection - Find slow disk reads
  4. Anomaly detection - Identify outlier suggestion latencies

Proposed Integration

Environment Variable Toggle

export APRENDER_RENACER=1        # Enable renacer tracing
export APRENDER_RENACER_OPTS="-c --stats-extended"  # Custom renacer flags

ZSH Widget Integration

_aprender_suggest() {
    [[ "$APRENDER_DISABLED" == "1" ]] && return
    
    local suggestion
    if [[ "$APRENDER_RENACER" == "1" ]]; then
        local renacer_opts="${APRENDER_RENACER_OPTS:--c}"
        suggestion=$(renacer $renacer_opts -- aprender-shell suggest "$BUFFER" 2>/tmp/aprender-renacer.log | head -1 | cut -f1)
    else
        suggestion=$(timeout 0.1 aprender-shell suggest "$BUFFER" 2>/dev/null | head -1 | cut -f1)
    fi
    # ... rest of function
}

CLI Subcommand

# Trace a single suggestion
aprender-shell trace suggest "git sta"

# Trace with full statistics
aprender-shell trace --stats suggest "git sta"

# Trace model training
aprender-shell trace train

Implementation:

Commands::Trace { renacer_args, subcommand } => {
    let status = Command::new("renacer")
        .args(&renacer_args)
        .arg("--")
        .arg("aprender-shell")
        .args(&subcommand)
        .status()?;
}

Output Example

$ APRENDER_RENACER=1 aprender-shell suggest "git "
git status

$ cat /tmp/aprender-renacer.log
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 45.23    0.000892          44        20           read
 32.11    0.000633          31        20           mmap
 12.45    0.000245          24        10           openat
  5.67    0.000112          11        10           close
------ ----------- ----------- --------- --------- ----------------
100.00    0.001972                    60           total

Dependencies

  • Requires renacer binary in PATH
  • Graceful degradation if not installed

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions