feat: add packet_size configuration for LOGIN7 message#400
Open
johndauphine wants to merge 1 commit intoprisma:mainfrom
Open
feat: add packet_size configuration for LOGIN7 message#400johndauphine wants to merge 1 commit intoprisma:mainfrom
johndauphine wants to merge 1 commit intoprisma:mainfrom
Conversation
Add the ability to configure the TDS packet size in the LOGIN7 message. Larger packet sizes can significantly improve bulk insert performance by reducing network round-trips and protocol overhead. The default packet size remains 4096 bytes for backwards compatibility. Valid values are 512 to 32767 bytes. The server may negotiate a different size than requested. Example usage: ```rust let mut config = Config::new(); config.packet_size(32767); // Request 32KB packets ``` Performance testing showed that increasing packet size from 4KB to 16KB improved bulk insert throughput by ~40% (from 104K to 178K rows/sec for a 19.3M row dataset).
johndauphine
added a commit
to johndauphine/mssql-pg-migrate-rs
that referenced
this pull request
Jan 2, 2026
…erts Use a fork of Tiberius that supports configurable TDS packet size. Increasing from default 4KB to 32KB (server negotiates to 16KB on Linux) provides a significant performance improvement for bulk insert operations. Benchmark results (PG→MSSQL, 19.3M rows): - Before (4KB packets): ~186s, 104K rows/sec - After (16KB packets): ~108s, 178K rows/sec - Improvement: 42% faster The fork adds packet_size configuration to Tiberius Config and LoginMessage. PR submitted upstream: prisma/tiberius#400 Once the upstream PR is merged, we can switch back to the official tiberius crate. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
johndauphine
added a commit
to johndauphine/mssql-pg-migrate-rs
that referenced
this pull request
Jan 2, 2026
…erts (#63) * perf: use Tiberius fork with 32KB packet size for 42% faster bulk inserts Use a fork of Tiberius that supports configurable TDS packet size. Increasing from default 4KB to 32KB (server negotiates to 16KB on Linux) provides a significant performance improvement for bulk insert operations. Benchmark results (PG→MSSQL, 19.3M rows): - Before (4KB packets): ~186s, 104K rows/sec - After (16KB packets): ~108s, 178K rows/sec - Improvement: 42% faster The fork adds packet_size configuration to Tiberius Config and LoginMessage. PR submitted upstream: prisma/tiberius#400 Once the upstream PR is merged, we can switch back to the official tiberius crate. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor: extract TDS packet size to named constant Address Copilot review comments: - Add TDS_MAX_PACKET_SIZE constant (32767 bytes) with documentation - Clarify that SQL Server on Linux negotiates to 16KB - Document the 42% performance improvement vs default 4KB 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
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.
Summary
Add the ability to configure the TDS packet size in the LOGIN7 message. Larger packet sizes can significantly improve bulk insert performance by reducing network round-trips and protocol overhead.
Motivation
While working on a high-throughput data migration tool, we discovered that the default 4KB packet size was a significant bottleneck for bulk insert operations. Benchmarking showed:
This is a 42% improvement in bulk insert performance simply by increasing the packet size.
For comparison, Go's
go-mssqldbdriver also defaults to 4KB packets, but exposes configuration. After this change, Rust/tiberius performance matches or exceeds Go for bulk operations.Changes
packet_size: Option<u32>field toConfigstructpacket_size(&mut self, size: u32)setter method with documentationget_packet_size(&self) -> Option<u32>getter methodLoginMessagein the connection flowpacket_size(&mut self, size: u32)setter toLoginMessageExample Usage
Technical Notes
Test Plan
cargo test --features rustls)🤖 Generated with Claude Code