Commit 0fc0ff8
committed
bindings: add crate and Go module with Service inter-op mechanism
A Service looks like a bidirectional channel, but is one which is
synchronously polled to send and receive framed message code and data
payloads. It's intended as a fundamental building block for building
bidirectional in-process streaming services that interoperate between
Go and Rust -- an interface which is a heck of a lot faster than gRPC.
It achieves zero-copy semantics by pushing Go []byte buffers down
into CGO invocations, and surfacing Rust-owned []byte arenas and
Frame payloads. There are some rules callers need to adhere to,
such as not scribbling "sent" memory until Poll() is called, and
not referencing Rust-owned memory returned by Poll() after _another_
Poll() call is made.
It amortizes the CGO overhead by vectorizing dispatch. On the Rust
side, some common functions are provided to monomorphize appropriate
bindings for an implementation of a Service trait.
Lies, damn lies, and benchmarks:
This shows a variety of stride patterns (number of sent messages
per Poll() call), some of which are deliberately worst case.
It's comparing the actual "upper case" service with a no-op service
that has the same setup & moving parts, but avoids the actual CGO
invocation itself.
Comparative benchmarks with equivalent "naive" CGO and "pure" Go
Services are included. These are also zero-copy / return owned
memory.
$ go test ./go/bindings/ -bench='.' -benchtime 3s
goos: linux
goarch: amd64
pkg: github.com/estuary/flow/go/bindings
BenchmarkUpperService/cgo-1-24 43781984 79.1 ns/op
BenchmarkUpperService/noop-1-24 270172464 13.3 ns/op
BenchmarkUpperService/cgo-3-24 48714016 72.2 ns/op
BenchmarkUpperService/noop-3-24 368625391 9.70 ns/op
BenchmarkUpperService/cgo-4-24 91550871 36.8 ns/op
BenchmarkUpperService/noop-4-24 363729646 10.1 ns/op
BenchmarkUpperService/cgo-11-24 77817141 45.2 ns/op
BenchmarkUpperService/noop-11-24 369495175 9.76 ns/op
BenchmarkUpperService/cgo-15-24 83527456 42.2 ns/op
BenchmarkUpperService/noop-15-24 382336641 9.84 ns/op
BenchmarkUpperService/cgo-17-24 135539218 27.0 ns/op
BenchmarkUpperService/noop-17-24 423105061 8.66 ns/op
BenchmarkUpperService/cgo-31-24 100000000 32.6 ns/op
BenchmarkUpperService/noop-31-24 406740273 9.10 ns/op
BenchmarkUpperService/cgo-32-24 151226794 23.7 ns/op
BenchmarkUpperService/noop-32-24 423966495 8.67 ns/op
BenchmarkUpperService/cgo-63-24 129356660 27.7 ns/op
BenchmarkUpperService/noop-63-24 426944920 8.82 ns/op
BenchmarkUpperService/cgo-137-24 150434529 23.9 ns/op
BenchmarkUpperService/noop-137-24 441497529 8.39 ns/op
BenchmarkUpperService/cgo-426-24 155104615 23.3 ns/op
BenchmarkUpperService/noop-426-24 452368488 8.30 ns/op
BenchmarkUpperServiceNaive-24 34605169 104 ns/op
BenchmarkUpperServiceGo-24 278482276 12.8 ns/op
PASS
ok github.com/estuary/flow/go/bindings 111.130s1 parent 4a30be1 commit 0fc0ff8
File tree
11 files changed
+1066
-0
lines changed- crates/bindings
- src
- go/bindings
11 files changed
+1066
-0
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments