Commit de48f30
committed
perf(http-pd): use shared SseEncoder for logprob-merge SSE re-encode
Replace the per-chunk `serde_json::to_string` + `format!("data: …")`
pair in `merge_streaming_logprobs` with the shared
`common::sse::SseEncoder`. A single encoder is created once per stream
in the `create_streaming_response` relay task and threaded into the
merge helper, so the serialization buffer is reused across every
re-encoded chunk (1 allocation per chunk instead of 2).
The idiosyncratic streaming-error frame in `handle_decode_error_response`
(`data: {'error': …}` without a trailing blank line) is left untouched to
avoid changing its wire format. No behavior change.
Signed-off-by: XinyueZhang369 <zoeyzhang369@gmail.com>1 parent cac6755 commit de48f30
1 file changed
Lines changed: 12 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
910 | 911 | | |
911 | 912 | | |
912 | 913 | | |
| 914 | + | |
| 915 | + | |
913 | 916 | | |
914 | 917 | | |
915 | 918 | | |
916 | 919 | | |
917 | 920 | | |
918 | 921 | | |
919 | | - | |
920 | | - | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
921 | 928 | | |
922 | 929 | | |
923 | 930 | | |
| |||
1138 | 1145 | | |
1139 | 1146 | | |
1140 | 1147 | | |
| 1148 | + | |
1141 | 1149 | | |
1142 | 1150 | | |
1143 | 1151 | | |
| |||
1168 | 1176 | | |
1169 | 1177 | | |
1170 | 1178 | | |
1171 | | - | |
1172 | | - | |
1173 | | - | |
1174 | | - | |
1175 | | - | |
1176 | | - | |
| 1179 | + | |
| 1180 | + | |
1177 | 1181 | | |
1178 | 1182 | | |
1179 | 1183 | | |
| |||
0 commit comments