Skip to content

251024 streamline message encoding - #105

Merged
zmstone merged 2 commits into
mainfrom
251024-stream-line-message-encoding
Oct 31, 2025
Merged

251024 streamline message encoding#105
zmstone merged 2 commits into
mainfrom
251024-stream-line-message-encoding

Conversation

@zmstone

@zmstone zmstone commented Oct 30, 2025

Copy link
Copy Markdown
Contributor

Add a sender process to offload wolff_producer process from encoding batches which may including

  • CRC32C NIF calls (for large batch, the call delegates to dirty scheduler)
  • Compression NIF calls

So wolff_producer can be more focused on taking send requests into replayq, and handling Kafka acknowledgements.

Benchmarked with 4 KB Payload to a single partition. When calling wolff:send2 (call return once enqueued)

  • ~10 % lower latency across all percentiles.
  • Slightly tighter distribution (less jitter).

@zmstone
zmstone force-pushed the 251024-stream-line-message-encoding branch from 523c5cc to 9b63243 Compare October 30, 2025 17:28
@zmstone
zmstone force-pushed the 251024-stream-line-message-encoding branch from 9b63243 to b141bf8 Compare October 30, 2025 18:21
Move Kafka batch encoding to another process to streamline
the work load. The wolff_producer process can be more responsive
to handle publish calls and Kafka replies.
@zmstone
zmstone force-pushed the 251024-stream-line-message-encoding branch from b141bf8 to 9ec0ae9 Compare October 30, 2025 18:27
@zmstone zmstone changed the title 251024 stream line message encoding 251024 streamline message encoding Oct 30, 2025
Comment thread src/wolff_producer.erl
erlang:process_flag(trap_exit, true),
ok = set_process_label(ClientId, Topic, Partition),
{ok, St, {continue, do_init}}.
{ok, Sender} = wolff_sender:start_link(self(), ClientId, Topic, Partition),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we rely a lot on this producer process not crashing/restarting to avoid losing queued data, doesn't this linking open up more opportunities to lose data? Maybe we should at least handle the exit signal from this process in a different manner than stop.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only reason for sender to exit is a crash, hence should link-exit owner.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exactly, maybe could restart the sender instead of losing the replayq?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i mean, it's like the crash bug is in wolff_producer itself.

@zmstone
zmstone merged commit f361949 into main Oct 31, 2025
4 checks passed
@zmstone
zmstone deleted the 251024-stream-line-message-encoding branch October 31, 2025 14:44
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.

2 participants