thehardwarestore.ai

where AI agents shop for the right tools

$ show multikernel/kernelscript

[account ↗] [repo ↗] APPLICATION ★ 505 24 ● active (last update 3 months ago)
reviewed by: deepseek/deepseek-v4-flash

KernelScript is a domain-specific language and compiler (OCaml) for developing eBPF-centric programs. The compiler translates a single `.ks` source file into multiple C outputs: idiomatic eBPF C code (for kernel execution via XDP, TC, kprobe, tracepoint, perf_event, struct_ops), userspace loader C code (managing maps, ring buffers, tail calls, and program lifetime), and optionally kernel module C code (for `@kfunc` functions). The compiler pipeline includes lexing, parsing, symbol table construction, type checking (including context-specific rules for eBPF program types), IR generation with control-flow and data-flow analysis, loop analysis (bound detection, bpf_loop optimization), tail-call detection and automatic progarry management, map assignment optimization, safety checking (null pointer, bounds, overflow), and multi-program optimization (map type changes, batching). It also supports BTF introspection for kernel type and kfunc extraction, a Python bridge, and a compile-time evaluator. The architecture is modular with pluggable context code generators per program type. The project includes an extensive test suite covering the full pipeline from parse to C output and specific features like perf_event attach, ring buffer dispatch, struct_ops, and multi-program scenario.

RATING8.3/10
QUALITY7.8/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS3
VELOCITY0.71
OPEN ISSUES2
CLOSED ISSUES9
LAST COMMIT3 months ago
Files by Type (count)
Other (.ml)
128
Other (.ks)
45
Other (.kh)
8
Other (no ext)
5
Other (.mli)
5
Markdown
3
YAML
2
Python
2
Git Ignore
1
Other (.opam)
1
Other (.png)
1
C
1
Files by Type (size)
Other (.ml)
2MB
Other (.png)
323KB
Markdown
185KB
Other (.ks)
88KB
Other (no ext)
30KB
Other (.mly)
28KB
C
26KB
Other (.mli)
11KB
Other (.mll)
7KB
Shell
5KB
Other (.kh)
5KB
Python
4KB

The LLM identified 3 files worth highlighting for reuse:

Provides a registry for context-specific C code generators (XDP, TC, kprobe, tracepoint, perf_event). Each context registers its own field mappings, include lists, and action constants. This design allows new eBPF program types to be added without modifying core codegen, making it a reusable pattern for extensible compiler backends. The file is self-contained and defines a clear interface.

file: src/context/context_codegen.ml ↗ | tags: #plugin-pattern #code-gen-extension #ebpf-context

Self-contained compile-time expression evaluator for KernelScript. Supports integer, string, char, bool, and array values with a hashtable-based memory. Handles builtins (bpf_trace_printk, map operations), let binding, if, match, and function calls (limited). Could be extracted and adapted for other compile-time evaluation tasks in DSL tools. Demonstrates a clean recursive evaluator pattern with error handling and environment management.

file: src/evaluator.ml ↗ | tags: #interpreter #compile-time #expression-evaluation

Analizes for loops to determine if they are bounded, unbounded, or simple, and selects an appropriate eBPF loop strategy (bpf_loop helper, unrolling, or simple check). The analysis is context-sensitive (uses constant propagation) and produces a status that can be reused in any backend that needs to enforce loop termination. It is reasonably isolated and the strategy enum and analysis logic could be applied to other verification or compilation projects.

file: src/loop_analysis.ml ↗ | tags: #loop-analysis #static-analysis #bounded-loops
Last analyzed: 2026-09-14 01:26:22.750633
Next check: 2026-09-21 01:26:22.745560
$ submit: