Skip to content

updated eventsource-stream to eventsource-stream2#559

Open
SneedSeedFeed wants to merge 2 commits into
64bit:mainfrom
SneedSeedFeed:eventsource-stream-update
Open

updated eventsource-stream to eventsource-stream2#559
SneedSeedFeed wants to merge 2 commits into
64bit:mainfrom
SneedSeedFeed:eventsource-stream-update

Conversation

@SneedSeedFeed
Copy link
Copy Markdown

eventsource-stream has not been updated since February of 2022. I ported my parser from sseer to eventsource-stream and opened a pr that fixes a performance issue, after emailing Julian a few months back I got no reply so I decided to fork it instead.

eventsource-stream2 is nearly exactly the same just with a faster parser and one less error variant since the parser can never actually error, so for async-openai it's literally just a drop-in replacement as you don't depend on the EventStreamError::Parser variant I removed. The change is so drop-in all I had to do was change the Cargo.toml lol.

In terms of real world performance uplift it wont be much but it should improve the worst case of large SSE lines, in some benchmarks I found a 50x uplift in the best case of a 1024 byte line with the average uplift being closer to 4x.

@SneedSeedFeed
Copy link
Copy Markdown
Author

SneedSeedFeed commented May 30, 2026

bumped the version to 0.4 which (should) be less likely to break semver in the future since there were some leftovers from the original that caught me out. Additionally the performance should be significantly improved by a further 4x or so since I've removed an intermediate stream and made the parser not re-scan the SSE line.

In informal testing (my benchmarks can only compare against myself not eventstream-source), an example that ran in 2.5s on eventsource-stream now runs in ~6ms so is about 400x faster in that worst case scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant