THRIFT-6147: Finalize buffered Ruby serializer transports - #3711
Merged
Conversation
Client: rb Co-Authored-By: OpenAI Codex (GPT-5.6) <codex@openai.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Ruby Thrift::Serializer returning empty strings when the selected protocol uses buffered/framed transports (e.g., Header, Framed) by ensuring the protocol’s exposed transport is finalized before reading from the backing MemoryBufferTransport.
Changes:
- Flush the protocol’s transport after writing (
@protocol.trans.flush) so buffered transports emit their wire representation before the serializer reads the buffer. - Expand serializer specs to cover framed and Header protocol round-trips, and assert byte-for-byte stability for common protocol outputs.
- Update existing protocol-factory-based serialization spec to expect a
flushon the protocol transport.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/rb/lib/thrift/serializer/serializer.rb | Flushes the protocol transport before reading the memory buffer to finalize buffered/framed outputs. |
| lib/rb/spec/serializer_spec.rb | Adds regression tests for framed and Header transports and checks output stability across standard protocols. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ruby
Serializerreads its backing memory buffer immediately after writing a value through the selected protocol. That produces the expected bytes for protocols writing directly toMemoryBufferTransport, but transports such as Header and Framed retain their output until they are flushed. In those configurations, serialization succeeds while returning an empty string.This change finalizes the transport exposed by the selected protocol before reading the serializer buffer. It relies on the existing transport contract: flushing a memory buffer remains a no-op, while buffering and framing transports complete their wire representation. The behavior therefore remains generic instead of coupling
Serializerto specific protocol or transport classes.Benchmarks
A targeted benchmark ran 50,000 ordinary serializer calls per protocol for five trials with:
The benchmark compared current master with this change under the same Ruby container and workload. Medians in seconds were:
The small differences are within run-to-run noise. This benchmark targets the existing direct-memory paths, where the new call resolves to a no-op flush. It does not compare Header or Framed throughput because master returns no serialized bytes for those configurations.
[skip ci]anywhere in the commit message to free up build resources.