Protobuf through ipx-wire costs more CPU than the JSON it replaced #470

Closed
opened 2026-11-16 15:44:02 -08:00 by rays · 1 comment
Owner

ipx-wire (#465) converts through prost-reflect and serde_json::Value at run time, so protobuf is JSON plus a conversion, never less. Measured in a release build on production's answers: decoding /api/feeds (1,488 feeds) takes 0.37 ms with serde_json, 0.09 ms with prost-generated structs, and 1.50 ms through ipx_wire::decode; /api/entries (50 items) 0.12, 0.03 and 0.21 ms. The server side does the same in reverse: GET /api/feeds as protobuf answered about 4 ms after JSON. So ipx's calls to the directory and ipx-play now spend about 4x the CPU they did. The fix is prost-generated types (prost-build from protox's descriptors in crates/wire/build.rs) where the bytes are made and read: the clients in ipx and, where it pays, the hot answers, instead of the dynamic conversion.

ipx-wire (#465) converts through prost-reflect and serde_json::Value at run time, so protobuf is JSON plus a conversion, never less. Measured in a release build on production's answers: decoding /api/feeds (1,488 feeds) takes 0.37 ms with serde_json, 0.09 ms with prost-generated structs, and 1.50 ms through ipx_wire::decode; /api/entries (50 items) 0.12, 0.03 and 0.21 ms. The server side does the same in reverse: GET /api/feeds as protobuf answered about 4 ms after JSON. So ipx's calls to the directory and ipx-play now spend about 4x the CPU they did. The fix is prost-generated types (prost-build from protox's descriptors in crates/wire/build.rs) where the bytes are made and read: the clients in ipx and, where it pays, the hot answers, instead of the dynamic conversion.
rays added the bug label 2026-11-16 15:44:02 -08:00
Author
Owner

Fixed in 236bd02 and deployed (directory, play, ipx, ipx-web): answers go from the handler's JSON into prost structs generated by crates/wire/build.rs, not through prost-reflect; ipx's calls to the directory and ipx-play use the structs directly. Live, best of five: /api/feeds 45 ms JSON, 47 ms protobuf (was about 4 ms behind); /api/entries 40 and 38 ms. The page now asks for protobuf too and reads it with web/src/wire.ts.

Fixed in 236bd02 and deployed (directory, play, ipx, ipx-web): answers go from the handler's JSON into prost structs generated by crates/wire/build.rs, not through prost-reflect; ipx's calls to the directory and ipx-play use the structs directly. Live, best of five: /api/feeds 45 ms JSON, 47 ms protobuf (was about 4 ms behind); /api/entries 40 and 38 ms. The page now asks for protobuf too and reads it with web/src/wire.ts.
rays closed this issue 2026-11-16 16:27:06 -08:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rays/ipx#470