summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-09-21 21:30:29 +0300
committerPaul Buetow <paul@buetow.org>2025-09-21 21:30:29 +0300
commitf5bcffa15b1279add0e26c96ed4e8ef0471dc06b (patch)
treebcbbab3c1d1383f27d70fd1275ed90add5a69298
parent4c367424d81722b0473cc65fd58fac3136ce13d3 (diff)
add agents remove CLAUDE.md
-rw-r--r--AGENTS.md50
-rw-r--r--CLAUDE.md108
2 files changed, 50 insertions, 108 deletions
diff --git a/AGENTS.md b/AGENTS.md
new file mode 100644
index 0000000..a2be14a
--- /dev/null
+++ b/AGENTS.md
@@ -0,0 +1,50 @@
+# AGENTS.md
+
+This file provides guidance to AI coding assistants working with the I/O Riot NG (ior) codebase.
+
+## Build/Test Commands
+
+**Prerequisites**: Ensure libbpfgo is cloned at `../libbpfgo` relative to this repository.
+
+```bash
+make all # Build everything (BPF objects and Go binary)
+make test # Run all tests
+make test_with_name TEST_NAME=TestEventloop # Run specific test
+go test ./internal/event -v # Run tests for specific package
+make generate # Generate code (required after modifying tracepoint definitions)
+make bench # Run benchmarks
+make clean # Clean build artifacts
+```
+
+## Code Generation
+
+**Run `make generate` before building when tracepoint definitions change!**
+
+Three Raku scripts generate code from Linux kernel tracepoint data:
+
+```bash
+make generate # Generate all code (C and Go)
+make -C internal/c generate # Generate C tracepoint handlers from /sys/kernel/tracing
+make -C internal/types generate # Generate Go types from C structs
+make -C internal/tracepoints generate # Generate Go tracepoint list
+```
+
+Generated files (do not edit manually):
+- `internal/c/generated_tracepoints.c` - BPF C handlers for syscall tracepoints
+- `internal/types/generated_types.go` - Go structs matching C structs + type mappings
+- `internal/tracepoints/generated_tracepoints.go` - List of available syscall tracepoints
+
+## Architecture
+
+- **Entry point**: `cmd/ior/main.go` - Linux-only BPF-based I/O syscall tracer
+- **Core packages**: `/internal/event/` (BPF event handling), `/internal/flamegraph/` (FlameGraph generation), `/internal/c/` (BPF programs)
+- **Output**: Compressed zstd files, collapsed stack format compatible with Inferno FlameGraphs
+
+## Code Style
+
+- Standard Go conventions with static linking (`-ldflags '-w -extldflags "-static"'`)
+- Keep functions under 50 lines, refactor larger code to `/internal/` packages
+- Use generated types from `/internal/types/generated_types.go` for kernel-userspace communication
+- BPF C code in `/internal/c/ior.bpf.c` should be minimal for verification
+- Import style: `"ior/internal/packagename"` for internal packages
+- Error handling: Return errors, don't panic except for setup validation
diff --git a/CLAUDE.md b/CLAUDE.md
deleted file mode 100644
index 7e9eb04..0000000
--- a/CLAUDE.md
+++ /dev/null
@@ -1,108 +0,0 @@
-# CLAUDE.md
-
-This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
-
-## Project Overview
-
-I/O Riot NG (ior) is a Linux system performance monitoring tool that traces synchronous I/O syscalls using BPF technology. It analyzes syscall execution time and generates FlameGraphs for performance visualization.
-
-## Build Commands
-
-**Prerequisites**: Ensure libbpfgo is cloned at `../libbpfgo` relative to this repository.
-
-```bash
-# Generate code (required after modifying tracepoint definitions)
-make generate
-
-# Build everything (BPF objects and Go binary)
-make all
-
-# Build only BPF objects
-make bpfbuild
-
-# Build only Go binary
-make gobuild
-
-# Build with race detector
-make gobuild_race
-
-# Clean build artifacts
-make clean
-
-# Deep clean (includes output files)
-make mrproper
-
-# Full rebuild (clean, generate, test, build)
-make world
-```
-
-## Testing Commands
-
-```bash
-# Run all tests
-make test
-
-# Run specific test
-make test_with_name TEST_NAME=TestEventloop
-
-# Run benchmarks
-make bench
-
-# Run Go tests directly
-go test ./internal/event -v
-go test ./internal/flamegraph -v
-```
-
-## Architecture Overview
-
-### Core Components
-
-1. **BPF Programs** (`/internal/c/`)
- - Kernel-side code that attaches to syscall tracepoints
- - Collects timing data with minimal overhead
- - Communicates with userspace via perf events
-
-2. **Event Processing** (`/internal/event/`)
- - Handles BPF events from kernel
- - Manages event loop and data collection
- - Key struct: `IorEvent` containing syscall timing data
-
-3. **FlameGraph Generation** (`/internal/flamegraph/`)
- - Converts raw events into collapsed stack format
- - Compatible with Inferno FlameGraph tools
- - Handles aggregation and sorting of stack traces
-
-4. **Code Generation**
- - Tracepoint definitions are generated from `/proc/kallsyms`
- - Uses Raku scripts to generate both Go and C code
- - Ensures consistency between kernel and userspace structures
-
-### Key Design Patterns
-
-- **Static Linking**: Binary is statically compiled for portability
-- **Platform-Specific**: Linux-only, enforced at compile time
-- **Output Compression**: Uses zstd for efficient storage
-- **Modular Structure**: Clear separation between BPF, event handling, and visualization
-
-## Development Guidelines
-
-### Adding New Syscall Tracepoints
-
-1. Modify the tracepoint generation scripts in `/internal/tracepoints/`
-2. Run `make generate` to regenerate code
-3. Update BPF programs in `/internal/c/` if needed
-4. Test with `make test` before building
-
-### Working with BPF Code
-
-- BPF C code is in `/internal/c/ior.bpf.c`
-- Keep BPF programs minimal for verification
-- Use perf events for kernel-userspace communication
-- Test on different kernel versions for compatibility
-
-### Code Style
-
-- Follow standard Go conventions
-- Keep functions under 50 lines (refactor into smaller functions)
-- For larger files, move code to appropriate packages under `/internal/`
-- Update comments to reflect code changes \ No newline at end of file