Skip to content
Snippets Groups Projects
  • Stepan Koltsov's avatar
    6a3d20bb
    Optimize shallow_clone for Bytes::split_{off,to} (#92) · 6a3d20bb
    Stepan Koltsov authored
    If `shallow_clone` is called with `&mut self`, and `Bytes` contains
    `Vec`, then expensive CAS can be avoided, because no other thread
    have references to this `Bytes` object.
    
    Bench `split_off_and_drop` difference:
    
    Before the diff:
    
    ```
    test split_off_and_drop             ... bench:      91,858 ns/iter (+/- 17,401)
    ```
    
    With the diff:
    
    ```
    test split_off_and_drop             ... bench:      81,162 ns/iter (+/- 17,603)
    ```
    6a3d20bb
    History
    Optimize shallow_clone for Bytes::split_{off,to} (#92)
    Stepan Koltsov authored
    If `shallow_clone` is called with `&mut self`, and `Bytes` contains
    `Vec`, then expensive CAS can be avoided, because no other thread
    have references to this `Bytes` object.
    
    Bench `split_off_and_drop` difference:
    
    Before the diff:
    
    ```
    test split_off_and_drop             ... bench:      91,858 ns/iter (+/- 17,401)
    ```
    
    With the diff:
    
    ```
    test split_off_and_drop             ... bench:      81,162 ns/iter (+/- 17,603)
    ```