feat: add packet_size configuration for LOGIN7 message#400
feat: add packet_size configuration for LOGIN7 message#400johndauphine 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).
…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>
…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>
|
Adding some cross-references in case they help prioritization:
This PR is the LOGIN7 piece of that same throughput story. The 42% improvement in the table above came from our high-throughput data migration tool (Rust → Postgres), where the 4KB default was the dominant bottleneck on the MSSQL read side. With 16KB packets the Stack Overflow 2010 dataset (19.3M rows across 10 tables) goes from ~104K to ~178K rows/sec end-to-end, putting Rust + tiberius at parity with go-mssqldb on the same workload — the only remaining difference between the two drivers here is configurability. The change is minimal (3 files, +32/-0), backwards compatible (default unchanged), and the server-negotiated value still flows through the existing |
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