Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,21 +216,23 @@ if err != nil {
|---------|-----------|--------|-----|
| C compiler required | No | No | Yes |
| API style | libffi-like (prepare once, call many) | reflect-based (RegisterFunc) | Native |
| Per-call allocations | Zero (CIF reusable) | sync.Pool per call | Zero |
| Struct pass/return | Full (RAX+RDX, sret) | Full | Full |
| Callback float returns | XMM0 in asm | panic | Full |
| ARM64 HFA detection | Recursive (nested structs) | Top-level only | Full |
| Per-call allocations | Zero (CIF reusable) | reflect + sync.Pool per call | Zero |
| Struct pass/return | Full (RAX+RDX, sret) | Partial (no Windows structs) | Full |
| Callback float returns | XMM0 in asm | Not supported (panic) | Full |
| ARM64 HFA detection | Recursive (nested structs) | Partial (bug in nested path) | Full |
| Typed errors | 5 types + errors.As() | Generic | N/A |
| Context support | Timeouts/cancellation | No | No |
| C-thread callbacks | crosscall2 | crosscall2 | Full |
| String/bool/slice args | Raw pointers only | Auto-marshaling | Full |
| Platform breadth | 6 targets | 9+ architectures | All |
| AMD64 overhead | 88–114 ns | ~100 ns | ~140 ns (Go 1.26) |
| Platform breadth | 6 targets | 8 GOARCH / 20+ OS×ARCH | All |
| AMD64 overhead | 88–114 ns | Not published | ~140 ns (Go 1.26 claims ~30% reduction) |

**Choose goffi** for GPU/real-time workloads: struct passing, zero per-call overhead, callback float returns, typed errors.

**Choose purego** for general-purpose bindings: string auto-marshaling, broad architecture support, less boilerplate.

**See also:** [JupiterRider/ffi](https://github.com/JupiterRider/ffi) — pure Go binding for libffi via purego. Supports struct pass/return and variadic functions; requires libffi at runtime.

---

## Known Limitations
Expand Down
6 changes: 3 additions & 3 deletions docs/PERFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,12 @@ FFI overhead: 0.0001ms = 0.001% ✅

| Aspect | goffi | purego |
|--------|-------|-------|
| **Overhead** | ~100 ns | ~100-150 ns |
| **Per-call allocations** | Zero (CIF reused) | sync.Pool per call |
| **Overhead** | ~100 ns | Not published |
| **Per-call allocations** | Zero (CIF reused) | reflect dispatch + sync.Pool per call |
| **Type Safety** | ✅ TypeDescriptor validation | Go reflect.Type |
| **Error Handling** | ✅ 5 typed errors | Generic errors |
| **Callback float returns** | ✅ XMM0 in asm | ❌ panic |
| **ARM64 HFA** | Recursive struct walk | Top-level only |
| **ARM64 HFA** | Recursive struct walk | Partial recursive (bug in nested path) |
| **Context support** | ✅ Timeouts/cancellation | ❌ |
| **Platforms** | 5 (quality focus) | 9+ (breadth focus) |

Expand Down
Loading