Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fix CQL Stitcher 1/4] Change StitchFrames API for protocols with str…
…eams only (#1689) Summary: This is the first of four PRs aimed at fixing an issue with the CQL stitcher discussed in #1375. It introduces an additional interface for `StitchFrames` for protocols with streams: ```cpp // interface for protocols with streams StitchFrames(absl::flat_hash_map<stream_id_t, std::deque<Frame>>* req_messages, absl::flat_hash_map<stream_id_t, std::deque<Frame>>* res_messages) ``` The old interface is retained for other protocols by default. To use the new map interface, protocols must have the `StreamSupport` enum set to `UseStream` in their `ProtocolTraits`. ```cpp // interface for protocols without a notion of streams i.e. which don't use streams for frame stitching StitchFrames(std::deque<Frame>* req_messages, std::deque<Frame>* res_messages) ``` This change should be a no op, as the default interface is used across the board. The next PR has the CQL stitcher and tests actually use it. Note that in PRs 1/4 and 2/4 the map is populated after parsing frames into request/response deques. PRs 3/4 and 4/4 populate the map earlier during parsing and has protocols without streams use the first key i.e. a single stream. This is a larger change and therefore separated. Related issues: #1375 Type of change: /kind bug Test Plan: Tested all existing targets - `bazel test ...` Performance: I've benchmarked the performance impact of this API change using a [new demo](https://github.com/benkilimnik/pixie-privy/tree/cql-perf-test) that cycles through streams. The demo uses a [fork of the datastax driver for cassandra](https://github.com/benkilimnik/python-driver) which I tinkered with to prevent stream ID reuse. This demo goes all the way up to `2^15-1`, the absolute worst case in terms of stream ID reuse. Note that this is probably a very unrealistic scenario (by default, this particular driver only goes up to 300 streams max), but it helps us test the limits of the map interface. As a sanity check, I also ran an experiment for the existing k8ssandra demo. Note that I only ran one experiment for each of k8ssandra and the bad-stream-reuse demos. More perf tests may be required to reliably assess performance impact, but this at least rules out a major degradation. Also, since this change is currently scoped to only the cassandra stitcher, it shouldn't impact any of the other protocols. ## Benchmark results ### Python demo poor stream ID reuse Baseline ![baseline_poor_stream_reuse](https://github.com/pixie-io/pixie/assets/47846691/2e7a99c8-c1bb-4dda-8dc2-202a2c35d18a) API change (including changes to CQL Stitcher to make use of new interface PR 2/3 #1715): streams up to `2^15-1` ![map_interface_poor_stream_reuse](https://github.com/pixie-io/pixie/assets/47846691/f946af12-f19f-4cac-9195-b9db709787ba) ### K8ssandra demo Baseline ![baseline_k8ssandra](https://github.com/pixie-io/pixie/assets/47846691/e564f680-5470-4cc2-9431-507c4c2323ae) API change (including changes to CQL Stitcher to make use of new interface in PR 2/3 #1715) ![map_interface_k8ssandra](https://github.com/pixie-io/pixie/assets/47846691/dcd5337f-d5fa-4ce2-9694-53f1ded37fa2) Signed-off-by: Benjamin Kilimnik <[email protected]>
- Loading branch information