Skip to content

Send fastlane frames as a shared binary - #6884

Merged
josevalim merged 1 commit into
phoenixframework:mainfrom
Snehil-Shah:dispatcher-encode-to-binary
Oct 28, 2026
Merged

josevalim merged 1 commit into
phoenixframework:mainfrom
Snehil-Shah:dispatcher-encode-to-binary

Conversation

@Snehil-Shah

Copy link
Copy Markdown
Contributor

Binaries >64 bytes (refc binaries) are shared between processes, so flattening the encoded frame avoids copying it for every subscriber process.

Some numbers

Time for one Phoenix.Channel.Server.broadcast/4:

Subscribers Payload Before After
1 1 KB 8 µs 7 µs
1 100 KB 0.9 ms 0.8 ms
100 1 KB 0.37 ms 0.12 ms
100 10 KB 3.1 ms 0.21 ms
100 100 KB 32.3 ms 1.8 ms
1,000 100 B 1.5 ms 1.0 ms
1,000 1 KB 3.7 ms 0.95 ms
1,000 10 KB 31.9 ms 1.0 ms
1,000 100 KB 299 ms 2.7 ms

@Snehil-Shah

Copy link
Copy Markdown
Contributor Author

We did this for Realtime's dispatcher as well (supabase/realtime#2405) and saw similar perf gain.

cc @edgurgel

@SteffenDE
SteffenDE requested a review from josevalim October 28, 2026 10:12
@josevalim
josevalim merged commit c9065a8 into phoenixframework:main Oct 28, 2026
16 checks passed
@josevalim

Copy link
Copy Markdown
Member

Very nice!

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.

3 participants