Add read-update-write benchmark

Update the README with a new benchmark group and performance results.
Include new data files and update the Rust benchmark implementation.
Regenerate UPB bindings and fix a data path in the C benchmark runner.
This commit is contained in:
2026-05-04 23:37:36 -07:00
parent a0c2747583
commit d21ff797b0
9 changed files with 505 additions and 329 deletions
+19 -6
View File
@@ -147,12 +147,13 @@ end offsets of the field range are recorded to bound iteration efficiently.
Two benchmark suites share the same binary data files and the same four
measurement groups:
| Group | What is timed |
| --------------- | ------------------------------------------------------- |
| `shallow_parse` | Become ready to read any field (one scan / full decode) |
| `deep_parse` | Walk the full tree: Campaign → Operations → Hackers |
| `field_access` | Read individual fields on an already-parsed message |
| `iterate` | Count top-level and nested repeated fields |
| Group | What is timed |
| ------------------- | ------------------------------------------------------- |
| `shallow_parse` | Become ready to read any field (one scan / full decode) |
| `deep_parse` | Walk the full tree: Campaign → Operations → Hackers |
| `field_access` | Read individual fields on an already-parsed message |
| `iterate` | Count top-level and nested repeated fields |
| `read_update_write` | Parse, update a field, and serialize back to a buffer |
### 1 — Generate the shared data files (do this once)
@@ -267,6 +268,18 @@ criterion medians; C/upb times are the custom runner's mean over ≥ 0.5 s.
> `shallow_parse`. `count_all_crew` also parses each `Operation` sub-message;
> roto's per-level scans remain cheaper than upb's full decode.
#### `read_update_write` — parse, update a field, and serialize back to a buffer
| Size | Bytes | roto (ns) | upb (ns) | roto speedup |
| ------ | --------: | --------: | ----------: | -----------: |
| tiny | 588 | 153.8 | 1,120.3 | **7.3×** |
| small | 20,265 | 1,301.8 | 42,089.6 | **32.3×** |
| medium | 2,071,053 | 302,090.0 | 9,233,397.9 | **30.5×** |
> roto's `with()` method allows copying fields directly from the original binary
> without decoding them, making the update process extremely efficient. upb must
> fully parse the message into structs and then re-serialize the entire tree.
### Interpreting the comparison
The two libraries have fundamentally different models: