3 ms·
> This standardizes on a interface to the kernel, not a language, right? It's a VM that runs JIT-compiled eBPF programs. You can write code in C or Golang or o
by ants_everywhere 3y ago
> This standardizes on a interface to the kernel, not a language, right?
It's a VM that runs JIT-compiled eBPF programs. You can write code in C or Golang or other languages that compiles down to eBPF. I did a video looking at the kernel eBPF code here: https://youtu.be/hznUH_zP77U?t=1165 https://youtu.be/hznUH_zP77U?t=1165
> wondering: what was the way to do it previously? Userland network tool?
My understanding is that userland network tools were common in fields like finance that needed fast custom networking and wanted to eliminate the overhead of context switching. I don't know how common they are/were in other fields though.
- shp0ngle 3y agogolang compiles to eBPF? including the whole golang runtime with garbage collector? that... surprises me edit: I don't see anything on the web that would show golang compiles to eBPF. I see bpf2go which is the other way around.
- thatloststudent 3y agoThis [1] makes me think gobpf uses C bindings to bcc, so golang does not compile to eBPF, bcc does. [1] - https://github.com/iovisor/gobpf/tree/master/bcc https://github.com/iovisor/gobpf/tree/master/bcc
- ants_everywhere 3y agoOh, no I don't mean that arbitrary Go compiles to eBPF. Apologies if I gave that impression. I meant that there are libraries that let you compose eBPF programs in other languages. But you're still putting together an eBPF program, just like you can assemble JSON with Go but you can't compile an arbitrary Go program to JSON. Cilium's eBPF library is the Go one I had in mind: https://github.com/cilium/ebpf https://github.com/cilium/ebpf Here's an example from that repo: https://github.com/cilium/ebpf/tree/main/examples/ringbuffer https://github.com/cilium/ebpf/tree/main/examples/ringbuffer
- spaceywilly 3y agoBPF works more like Java, where you have your high-level source code, then a JIT compiler translates it to bytecode that runs on a VM. Even BPF “programs” written in C aren’t using a standard C compiler. The BPF JIT compiler translates them to bytecode. The subset of C you can use is fairly limited, only what their compiler supports. So what people have done is written compilers that can take Go or Python and compile it to BPF bytecode.