Skip to content

Commit 6081352

Browse files
authored
Merge pull request #1337 from spacejam/tyler_debugging
various CI debugging efforts
2 parents ef6f32c + 7ce8209 commit 6081352

File tree

25 files changed

+317
-131
lines changed

25 files changed

+317
-131
lines changed

.github/workflows/test.yml

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ jobs:
3232
steps:
3333
- uses: actions/checkout@v1
3434
- name: Cache target
35-
uses: actions/cache@v1
35+
uses: actions/cache@v2
3636
env:
37-
cache-name: cache-target
37+
cache-name: cache-default-target-and-lockfile
3838
with:
39-
path: target
40-
key: ${{ runner.os }}-${{ env.cache-name }}
41-
restore-keys: |
42-
${{ runner.os }}-
39+
path: |
40+
target
41+
Cargo.lock
42+
~/.rustup
43+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}
4344
- name: linux coredump setup
4445
if: ${{ runner.os == 'linux' }}
4546
run: |
@@ -53,23 +54,25 @@ jobs:
5354
- uses: actions/upload-artifact@v2
5455
if: ${{ failure() && runner.os == 'linux' }}
5556
with:
56-
name: core-dump-upload
57+
name: linux-core-dumps
5758
path: |
5859
./core-dumps/*
60+
./target/release/deps/test_*
5961
examples:
6062
name: Example Tests
6163
runs-on: ubuntu-latest
6264
steps:
6365
- uses: actions/checkout@v1
6466
- name: Cache target
65-
uses: actions/cache@v1
67+
uses: actions/cache@v2
6668
env:
67-
cache-name: cache-target
69+
cache-name: cache-examples-target-and-lockfile
6870
with:
69-
path: target
70-
key: ${{ runner.os }}-${{ env.cache-name }}
71-
restore-keys: |
72-
${{ runner.os }}-
71+
path: |
72+
target
73+
Cargo.lock
74+
~/.rustup
75+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}
7376
- name: example tests
7477
run: |
7578
rustup update --no-self-update
@@ -88,27 +91,27 @@ jobs:
8891
burn-in:
8992
name: Burn In
9093
env:
91-
RUSTFLAGS: "-C target-cpu=native -C link-args=-Wl,-zstack-size=4194304"
9294
RUST_BACKTRACE: 1
9395
runs-on: ubuntu-latest
9496
steps:
9597
- uses: actions/checkout@v1
9698
- name: Cache target
97-
uses: actions/cache@v1
99+
uses: actions/cache@v2
98100
env:
99-
cache-name: cache-target
101+
cache-name: cache-stress2-target-and-lockfile
100102
with:
101-
path: target
102-
key: ${{ runner.os }}-${{ env.cache-name }}
103-
restore-keys: |
104-
${{ runner.os }}-
103+
path: |
104+
benchmarks/stress2/target
105+
benchmarks/stress2/Cargo.lock
106+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}
105107
- name: burn in
106108
run: |
107109
set -eo pipefail
108110
pushd benchmarks/stress2
109111
ulimit -c unlimited
110112
echo "$PWD/core-dumps/corefile-%e-%p-%t" | sudo tee /proc/sys/kernel/core_pattern
111113
mkdir core-dumps
114+
rm -rf default.sled || true
112115
cargo run --release -- --duration=60
113116
rm -rf default.sled
114117
- name: print backtraces with gdb
@@ -127,7 +130,7 @@ jobs:
127130
- uses: actions/upload-artifact@v2
128131
if: ${{ failure() }}
129132
with:
130-
name: core-dump-upload
133+
name: linux-core-dumps
131134
path: |
132135
./benchmarks/stress2/core-dumps/*
133136
./benchmarks/stress2/target/release/stress2
@@ -139,14 +142,15 @@ jobs:
139142
steps:
140143
- uses: actions/checkout@v1
141144
- name: Cache rustup
142-
uses: actions/cache@v1
145+
uses: actions/cache@v2
143146
env:
144-
cache-name: cache-target
147+
cache-name: cache-sanitizers-target-and-lockfile
145148
with:
146-
path: ~/.rustup
147-
key: ${{ runner.os }}-${{ env.cache-name }}
148-
restore-keys: |
149-
${{ runner.os }}-
149+
path: |
150+
~/.rustup
151+
benchmarks/stress2/target
152+
benchmarks/stress2/Cargo.lock
153+
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }}
150154
- name: sanitizers
151155
run: |
152156
set -eo pipefail

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@
4848
platforms and 512mb on 32-bit platforms.
4949
* #1281 `Config`'s `cache_capacity` is now a usize, as u64
5050
doesn't make sense for things that must fit in memory anyway.
51-
* #1319 Bump MSRV to 1.46.
5251
* #1314 `Subscriber::next_timeout` now requires a mutable self
5352
reference.
53+
* #1337 Bump MSRV to 1.48.
54+
5455

5556
## Bug Fixes
5657

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ default = []
3030
# internal testing use only. It injects many delays and performs several
3131
# test-only configurations that cause performance to drop significantly.
3232
# It will cause your tests to take much more time, and possibly time out etc...
33-
testing = ["event_log", "lock_free_delays", "compression", "failpoints", "backtrace"]
33+
testing = ["event_log", "lock_free_delays", "light_testing"]
34+
light_testing = ["compression", "failpoints", "backtrace", "memshred"]
3435
compression = ["zstd"]
3536
lock_free_delays = []
3637
failpoints = []
@@ -44,10 +45,11 @@ io_uring = ["rio"]
4445
docs = []
4546
miri_optimizations = []
4647
mutex = []
48+
memshred = []
4749

4850
[dependencies]
4951
libc = "0.2.81"
50-
zstd = { version = "0.7.0", optional = true }
52+
zstd = { version = "0.8", optional = true }
5153
crc32fast = "1.2.1"
5254
log = "0.4.11"
5355
parking_lot = "0.11.1"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ extreme::run(async move {
161161

162162
# minimum supported Rust version (MSRV)
163163

164-
We support Rust 1.46.0 and up.
164+
We support Rust 1.48.0 and up.
165165

166166
# architecture
167167

benchmarks/stress2/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ measure_allocs = ["sled/measure_allocs"]
2424
jemalloc = ["jemallocator"]
2525
logging = ["env_logger", "log", "color-backtrace"]
2626
dh = ["dhat"]
27+
memshred = []
2728

2829
[dependencies]
2930
rand = "0.7.3"

benchmarks/stress2/src/main.rs

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,47 @@ use std::{
66
thread,
77
};
88

9-
#[cfg(feature = "jemalloc")]
10-
use jemallocator::Jemalloc;
11-
129
#[cfg(feature = "dh")]
1310
use dhat::{Dhat, DhatAlloc};
1411

1512
use num_format::{Locale, ToFormattedString};
1613
use rand::{thread_rng, Rng};
1714

18-
#[global_allocator]
1915
#[cfg(feature = "jemalloc")]
20-
static ALLOCATOR: Jemalloc = Jemalloc;
16+
mod alloc {
17+
use std::alloc::Layout;
18+
use jemallocator::Jemalloc;
19+
20+
#[global_allocator]
21+
static ALLOCATOR: Jemalloc = Jemalloc;
22+
}
23+
24+
#[cfg(feature = "memshred")]
25+
mod alloc {
26+
use std::alloc::{System, Layout};
27+
28+
#[global_allocator]
29+
static ALLOCATOR: Alloc = Alloc;
30+
31+
#[derive(Default, Debug, Clone, Copy)]
32+
struct Alloc;
33+
34+
unsafe impl std::alloc::GlobalAlloc for Alloc {
35+
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
36+
let ret = System.alloc(layout);
37+
assert_ne!(ret, std::ptr::null_mut());
38+
std::ptr::write_bytes(ret, 0xa1, layout.size());
39+
ret
40+
}
41+
42+
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
43+
std::ptr::write_bytes(ptr, 0xde, layout.size());
44+
System.dealloc(ptr, layout)
45+
46+
}
47+
}
48+
}
49+
2150

2251
#[global_allocator]
2352
#[cfg(feature = "dh")]

scripts/cross_compile.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ rustup update --no-self-update
1212

1313
RUSTFLAGS="--cfg miri" cargo check
1414

15-
rustup toolchain install 1.46.0 --no-self-update
15+
rustup toolchain install 1.48.0 --no-self-update
1616
cargo clean
1717
rm Cargo.lock
18-
cargo +1.46.0 check
18+
cargo +1.48.0 check
1919

2020
for target in $targets; do
2121
echo "setting up $target..."

scripts/sanitizers.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,22 @@ set -eo pipefail
33

44
pushd benchmarks/stress2
55

6-
rustup toolchain install nightly --no-self-update
7-
rustup update --no-self-update
6+
rustup toolchain install nightly
7+
rustup toolchain install nightly --component rust-src
8+
rustup update
89

910
export SLED_LOCK_FREE_DELAY_INTENSITY=2000
1011

12+
echo "msan"
13+
cargo clean
14+
export RUSTFLAGS="-Zsanitizer=memory -Zsanitizer-memory-track-origins"
15+
cargo +nightly build -Zbuild-std --target x86_64-unknown-linux-gnu
16+
sudo rm -rf default.sled
17+
sudo target/x86_64-unknown-linux-gnu/debug/stress2 --duration=30 --set-prop=100000000 --val-len=1000 --entries=100 --threads=100
18+
sudo target/x86_64-unknown-linux-gnu/debug/stress2 --duration=30 --entries=100
19+
sudo target/x86_64-unknown-linux-gnu/debug/stress2 --duration=30
20+
unset MSAN_OPTIONS
21+
1122
echo "asan"
1223
cargo clean
1324
export RUSTFLAGS="-Z sanitizer=address"

src/config.rs

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -538,33 +538,17 @@ impl Config {
538538
{
539539
use fs2::FileExt;
540540

541-
let try_lock = if cfg!(feature = "testing") {
542-
// we block here because during testing
543-
// there are many filesystem race condition
544-
// that happen, causing locks to be held
545-
// for long periods of time, so we should
546-
// block to wait on reopening files.
547-
let start = std::time::Instant::now();
548-
loop {
549-
let ret = file.try_lock_exclusive();
550-
551-
if ret.is_ok() {
552-
break ret;
553-
}
554-
555-
if start.elapsed() > std::time::Duration::from_secs(10) {
556-
log::error!(
557-
"failed to open file in exclusive mode: {:?}",
558-
ret
559-
);
560-
break ret;
561-
}
562-
563-
std::thread::sleep(std::time::Duration::from_millis(50));
564-
}
565-
} else {
566-
file.try_lock_exclusive()
567-
};
541+
let try_lock =
542+
if cfg!(any(feature = "testing", feature = "light_testing")) {
543+
// we block here because during testing
544+
// there are many filesystem race condition
545+
// that happen, causing locks to be held
546+
// for long periods of time, so we should
547+
// block to wait on reopening files.
548+
file.lock_exclusive()
549+
} else {
550+
file.try_lock_exclusive()
551+
};
568552

569553
if let Err(e) = try_lock {
570554
return Err(Error::Io(io::Error::new(
@@ -774,6 +758,16 @@ impl Deref for RunningConfig {
774758
}
775759
}
776760

761+
#[cfg(all(not(miri), any(windows, target_os = "linux", target_os = "macos")))]
762+
impl Drop for RunningConfig {
763+
fn drop(&mut self) {
764+
use fs2::FileExt;
765+
if Arc::strong_count(&self.file) == 1 {
766+
let _ = self.file.unlock();
767+
}
768+
}
769+
}
770+
777771
impl Drop for Inner {
778772
fn drop(&mut self) {
779773
if self.temporary {

src/db.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const DEFAULT_TREE_ID: &[u8] = b"__sled__default";
1212
/// to disk, using the same method used by
1313
/// `Tree::flush`.
1414
#[derive(Clone)]
15+
#[doc(alias = "database")]
1516
pub struct Db {
1617
#[doc(hidden)]
1718
pub context: Context,

0 commit comments

Comments
 (0)