Protobuf through ipx-wire costs more CPU than the JSON it replaced #470
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
Fixed in
236bd02and 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.