mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-08 00:00:26 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6fdb7391ce | ||
|
|
025bec2954 | ||
|
|
2d51809bd7 | ||
|
|
7daa7fe053 | ||
|
|
972f538b7e | ||
|
|
81550da474 | ||
|
|
90e7e650c9 | ||
|
|
bc4a6d56f4 | ||
|
|
3603cec7c2 | ||
|
|
5cde647c29 |
@@ -66,7 +66,8 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install Rust
|
||||
run: rustup update stable && rustup default stable
|
||||
# --no-self-update is necessary because the windows environment cannot self-update rustup.exe.
|
||||
run: rustup update stable --no-self-update && rustup default stable
|
||||
- name: Test
|
||||
run: . ci/test-stable.sh test
|
||||
|
||||
@@ -120,7 +121,9 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install Rust
|
||||
run: rustup update nightly && rustup default nightly
|
||||
- name: TSAN / MSAN
|
||||
- name: Install rust-src
|
||||
run: rustup component add rust-src
|
||||
- name: ASAN / TSAN
|
||||
run: . ci/tsan.sh
|
||||
|
||||
# Loom
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
# 0.5.6 (July 13, 2020)
|
||||
|
||||
- Improve `BytesMut` to reuse buffer when fully `advance`d.
|
||||
- Mark `BytesMut::{as_mut, set_len}` with `#[inline]`.
|
||||
- Relax synchronization when cloning in shared vtable of `Bytes`.
|
||||
- Move `loom` to `dev-dependencies`.
|
||||
|
||||
# 0.5.5 (June 18, 2020)
|
||||
|
||||
### Added
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ name = "bytes"
|
||||
# - Update CHANGELOG.md.
|
||||
# - Update doc URL.
|
||||
# - Create "v0.5.x" git tag.
|
||||
version = "0.5.5"
|
||||
version = "0.5.6"
|
||||
license = "MIT"
|
||||
authors = [
|
||||
"Carl Lerche <[email protected]>",
|
||||
@@ -30,5 +30,5 @@ serde = { version = "1.0.60", optional = true, default-features = false, feature
|
||||
[dev-dependencies]
|
||||
serde_test = "1.0"
|
||||
|
||||
[target.'cfg(loom)'.dependencies]
|
||||
[target.'cfg(loom)'.dev-dependencies]
|
||||
loom = "0.3"
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#![feature(test)]
|
||||
#![deny(warnings, rust_2018_idioms)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
extern crate test;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#![feature(test)]
|
||||
#![deny(warnings, rust_2018_idioms)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
extern crate test;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#![feature(test)]
|
||||
#![deny(warnings, rust_2018_idioms)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
extern crate test;
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
# TSAN suppressions file for `bytes`
|
||||
|
||||
# TSAN does not understand fences and `Arc::drop` is implemented using a fence.
|
||||
# This causes many false positives.
|
||||
race:Arc*drop
|
||||
race:arc*Weak*drop
|
||||
|
||||
# `std` mpsc is not used in any Bytes code base. This race is triggered by some
|
||||
# rust runtime logic.
|
||||
race:std*mpsc_queue
|
||||
|
||||
# Some test runtime races. Allocation should be race free
|
||||
race:alloc::alloc
|
||||
|
||||
# Not sure why this is warning, but it is in the test harness and not the library.
|
||||
race:TestEvent*clone
|
||||
race:test::run_tests_console::*closure
|
||||
|
||||
# Probably more fences in std.
|
||||
race:__call_tls_dtors
|
||||
|
||||
# This ignores a false positive caused by `thread::park()`/`thread::unpark()`.
|
||||
# See: https://github.com/rust-lang/rust/pull/54806#issuecomment-436193353
|
||||
race:pthread_cond_destroy
|
||||
+1
-3
@@ -2,9 +2,7 @@
|
||||
|
||||
set -ex
|
||||
|
||||
export RUST_TEST_THREADS=1
|
||||
export ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0"
|
||||
export TSAN_OPTIONS="suppressions=$(pwd)/ci/tsan"
|
||||
|
||||
# Run address sanitizer
|
||||
RUSTFLAGS="-Z sanitizer=address" \
|
||||
@@ -12,4 +10,4 @@ cargo test --target x86_64-unknown-linux-gnu --test test_bytes --test test_buf -
|
||||
|
||||
# Run thread sanitizer
|
||||
RUSTFLAGS="-Z sanitizer=thread" \
|
||||
cargo test --target x86_64-unknown-linux-gnu --test test_bytes --test test_buf --test test_buf_mut
|
||||
cargo -Zbuild-std test --target x86_64-unknown-linux-gnu --test test_bytes --test test_buf --test test_buf_mut
|
||||
|
||||
+1
-1
@@ -928,7 +928,7 @@ const KIND_VEC: usize = 0b1;
|
||||
const KIND_MASK: usize = 0b1;
|
||||
|
||||
unsafe fn shared_clone(data: &AtomicPtr<()>, ptr: *const u8, len: usize) -> Bytes {
|
||||
let shared = data.load(Ordering::Acquire);
|
||||
let shared = data.load(Ordering::Relaxed);
|
||||
shallow_clone_arc(shared as _, ptr, len)
|
||||
}
|
||||
|
||||
|
||||
+11
-6
@@ -22,8 +22,12 @@ use crate::{Buf, BufMut, Bytes};
|
||||
///
|
||||
/// `BytesMut` represents a unique view into a potentially shared memory region.
|
||||
/// Given the uniqueness guarantee, owners of `BytesMut` handles are able to
|
||||
/// mutate the memory. It is similar to a `Vec<u8>` but with less copies and
|
||||
/// allocations.
|
||||
/// mutate the memory.
|
||||
///
|
||||
/// `BytesMut` can be thought of as containing a `buf: Arc<Vec<u8>>`, an offset
|
||||
/// into `buf`, a slice length, and a guarantee that no other `BytesMut` for the
|
||||
/// same `buf` overlaps with its slice. That guarantee means that a write lock
|
||||
/// is not required.
|
||||
///
|
||||
/// # Growth
|
||||
///
|
||||
@@ -475,6 +479,7 @@ impl BytesMut {
|
||||
///
|
||||
/// assert_eq!(&b[..], b"hello world");
|
||||
/// ```
|
||||
#[inline]
|
||||
pub unsafe fn set_len(&mut self, len: usize) {
|
||||
debug_assert!(len <= self.cap, "set_len out of bounds");
|
||||
self.len = len;
|
||||
@@ -558,9 +563,8 @@ impl BytesMut {
|
||||
unsafe {
|
||||
let (off, prev) = self.get_vec_pos();
|
||||
|
||||
// Only reuse space if we stand to gain at least capacity/2
|
||||
// bytes of space back
|
||||
if off >= additional && off >= (self.cap / 2) {
|
||||
// Only reuse space if we can satisfy the requested additional space.
|
||||
if self.capacity() - self.len() + off >= additional {
|
||||
// There's space - reuse it
|
||||
//
|
||||
// Just move the pointer back to the start after copying
|
||||
@@ -1025,6 +1029,7 @@ impl Deref for BytesMut {
|
||||
}
|
||||
|
||||
impl AsMut<[u8]> for BytesMut {
|
||||
#[inline]
|
||||
fn as_mut(&mut self) -> &mut [u8] {
|
||||
self.as_slice_mut()
|
||||
}
|
||||
@@ -1495,7 +1500,7 @@ static SHARED_VTABLE: Vtable = Vtable {
|
||||
};
|
||||
|
||||
unsafe fn shared_v_clone(data: &AtomicPtr<()>, ptr: *const u8, len: usize) -> Bytes {
|
||||
let shared = data.load(Ordering::Acquire) as *mut Shared;
|
||||
let shared = data.load(Ordering::Relaxed) as *mut Shared;
|
||||
increment_shared(shared);
|
||||
|
||||
let data = AtomicPtr::new(shared as _);
|
||||
|
||||
+2
-7
@@ -1,14 +1,9 @@
|
||||
#![deny(
|
||||
warnings,
|
||||
missing_docs,
|
||||
missing_debug_implementations,
|
||||
rust_2018_idioms
|
||||
)]
|
||||
#![warn(missing_docs, missing_debug_implementations, rust_2018_idioms)]
|
||||
#![doc(test(
|
||||
no_crate_inject,
|
||||
attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables))
|
||||
))]
|
||||
#![doc(html_root_url = "https://docs.rs/bytes/0.5.5")]
|
||||
#![doc(html_root_url = "https://docs.rs/bytes/0.5.6")]
|
||||
#![no_std]
|
||||
|
||||
//! Provides abstractions for working with bytes.
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#![deny(warnings, rust_2018_idioms)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use bytes::Buf;
|
||||
#[cfg(feature = "std")]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![deny(warnings, rust_2018_idioms)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use bytes::buf::IoSliceMut;
|
||||
|
||||
+17
-1
@@ -1,4 +1,4 @@
|
||||
#![deny(warnings, rust_2018_idioms)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use bytes::{Buf, BufMut, Bytes, BytesMut};
|
||||
|
||||
@@ -929,6 +929,22 @@ fn bytes_buf_mut_advance() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bytes_buf_mut_reuse_when_fully_consumed() {
|
||||
use bytes::{Buf, BytesMut};
|
||||
let mut buf = BytesMut::new();
|
||||
buf.reserve(8192);
|
||||
buf.extend_from_slice(&[0u8; 100][..]);
|
||||
|
||||
let p = &buf[0] as *const u8;
|
||||
buf.advance(100);
|
||||
|
||||
buf.reserve(8192);
|
||||
buf.extend_from_slice(b" ");
|
||||
|
||||
assert_eq!(&buf[0] as *const u8, p);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn bytes_reserve_overflow() {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#![deny(warnings, rust_2018_idioms)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use bytes::buf::{BufExt, BufMutExt};
|
||||
use bytes::{Buf, BufMut, Bytes};
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#![deny(warnings, rust_2018_idioms)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use bytes::Bytes;
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#![deny(warnings, rust_2018_idioms)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use bytes::Bytes;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![deny(warnings, rust_2018_idioms)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
#![cfg(feature = "std")]
|
||||
|
||||
use std::io::{BufRead, Read};
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#![cfg(feature = "serde")]
|
||||
#![deny(warnings, rust_2018_idioms)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use serde_test::{assert_tokens, Token};
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
#![deny(warnings, rust_2018_idioms)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
||||
use bytes::buf::{Buf, BufExt};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user