ai
ai copied to clipboard
Improve performance of eventsource parser
Description
This is a follow up to https://github.com/vercel/ai/issues/5325#issuecomment-2756747066.
I created a simple benchmark that compares @rexxars eventsource-parser and @ai-sdk/provider-utils' own implementation based on the bug report by @wong2:
https://github.com/gr2m/eventsource-parser-benchmark/#readme
Based on this particular use case, eventsource-parser-3.0.1 is
- ~100x faster than
eventsource-parser-3.0.0, and - ~10x faster than
@ai-sdk/provider-utils' own implementation
I couldn't yet figure out where the performance difference between eventsource-parser-3.0.1 and @ai-sdk/provider-utils' own implementation is coming from. I'll look more into it this coming week