Skip to content

Performance improvement - handling buffers in plp.rs #226

Closed

Description

@JasonCookSyncadd

Requesting single bytes from a tcp/ip stack incurs significant overhead.

I made a quick change to buffer coercion in src/tds/codec/column_data/plp.rs and in my specific case, performance improved by a factor of 3 (in my case when utilizing varchar).

The changes I made were as follows:
in fn decode
(comment this for loop out)
//for _ in 0..len {
// data.push(src.read_u8().await?);
//}
(replace with this)
data.resize(len as usize, 0u8); // actually allocate the space
src.read(&mut data).await?; // bulk read the data

Last else loop of decode (my case did not test this, concept code only):
//let byte = src.read_u8().await?;
//chunk_data_left -= 1;

//data.push(byte);
let mut buffer=Vec::with_capacity(chunk_data_left); // create a temporary storage for block
buffer.resize(chunk_data_left,0u8); // actually allocate the space
src.read(&mut buffer).await?; // bulk read the data
data.extend_from_slice(&buffer);
chunk_data_left=0;

Activity

  1. changed the title [-]Performance improvement - handling strings in plp.rs[/-] [+]Performance improvement - handling buffers in plp.rs[/+] on Jun 10, 2022
  2. MattJackson commented on Sep 18, 2026

    @MattJackson
    Contributor

    FYI: this is implemented in #449 (s9), currently in review. It'll be closed when that PR merges.

  3. MattJackson commented on Sep 24, 2026

    @MattJackson
    Contributor
  4. JasonCookSyncadd commented on Sep 24, 2026

    @JasonCookSyncadd
    Author

    Thank you! I'll be able to utilize soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions