Skip to content

Commit 416e48c

Browse files
committed
Split stable versus nightly for memory usage tests
**Description** Add a check for the `nightly` feature flag to change the expected sizes in different tests. This seems like a short-term solution because the nightly changes will eventually get promoted to stable and then this change will need to be removed. I found a possibly related [rust-lang issue #104807][rust-issue-104807] , maybe the fix for this will change the nightly enum sizes back to their previous values **Motivation** CI was breaking on the nightly and miri tests **Testing Done** - `cargo +nightly test --features nightly` passes - `cargo +nightly miri test` passes - `cargo +nightly test` fails [rust-issue-104807]: rust-lang/rust#104807
1 parent 195dcdf commit 416e48c

File tree

6 files changed

+41
-11
lines changed

6 files changed

+41
-11
lines changed

src/nodes/representation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ impl<V> fmt::Debug for ConcreteNodePtr<V> {
329329
pub struct NodePtr<N: Node>(NonNull<N>);
330330

331331
impl<N: Node> NodePtr<N> {
332-
/// Create a safe pointer to a Node_.
332+
/// Create a safe pointer to a [`Node`].
333333
///
334334
/// # Safety
335335
///

src/nodes/representation/tests.rs

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,39 @@ fn opaque_node_ptr_is_correct() {
2525
#[test]
2626
#[cfg(target_pointer_width = "64")]
2727
fn node_sizes() {
28-
assert_eq!(mem::size_of::<Header>(), 32);
28+
let expected_header_size = if cfg!(any(miri, feature = "nightly")) {
29+
40
30+
} else {
31+
32
32+
};
33+
34+
assert_eq!(mem::size_of::<Header>(), expected_header_size);
2935
// key map: 4 * (1 byte) = 4 bytes
3036
// child map: 4 * (8 bytes (on 64-bit platform)) = 32
3137
//
3238
// 4 bytes of padding are inserted after the `keys` field to align the field to
3339
// an 8 byte boundary.
34-
assert_eq!(mem::size_of::<InnerNode4<usize>>(), 72);
40+
assert_eq!(
41+
mem::size_of::<InnerNode4<usize>>(),
42+
expected_header_size + 40
43+
);
3544
// key map: 16 * (1 byte) = 16 bytes
3645
// child map: 16 * (8 bytes (on 64-bit platform)) = 128
37-
assert_eq!(mem::size_of::<InnerNode16<usize>>(), 176);
46+
assert_eq!(
47+
mem::size_of::<InnerNode16<usize>>(),
48+
expected_header_size + 144
49+
);
3850
// key map: 256 * (1 byte) = 256 bytes
3951
// child map: 48 * (8 bytes (on 64-bit platform)) = 384
40-
assert_eq!(mem::size_of::<InnerNode48<usize>>(), 672);
52+
assert_eq!(
53+
mem::size_of::<InnerNode48<usize>>(),
54+
expected_header_size + 640
55+
);
4156
// child & key map: 256 * (8 bytes (on 64-bit platform)) = 2048
42-
assert_eq!(mem::size_of::<InnerNode256<usize>>(), 2080);
57+
assert_eq!(
58+
mem::size_of::<InnerNode256<usize>>(),
59+
expected_header_size + 2048
60+
);
4361

4462
// Assert that pointer is expected size and has non-null optimization
4563
assert_eq!(mem::size_of::<Option<OpaqueNodePtr<()>>>(), 8);

src/nodes/visitor/pretty_printer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ use std::{
77
io::{self, Write},
88
};
99

10-
/// Settings which custom the output of the [`DotPrinter`] visitor.
10+
/// Settings which customize the output of the [`DotPrinter`] visitor.
1111
#[derive(Debug, Clone, PartialEq, Eq, Default)]
1212
pub struct DotPrinterSettings {
1313
/// Add node address to output in graphs
1414
pub display_node_address: bool,
1515
}
1616

17-
/// A visitor the the radix trie that will print the tree in "dot" notation.
17+
/// A visitor of the radix trie that will print the tree in "dot" notation.
1818
///
1919
/// See ['DOT Language | Graphviz'](https://graphviz.org/doc/info/lang.html) for
2020
/// information about syntax and example of the language.

tests/memory_usage_fixed_length_dense.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,11 @@ fn test_memory_usage() {
4545
dhat::assert_eq!(stats.curr_bytes, 0);
4646

4747
dhat::assert_eq!(stats.max_blocks, 398);
48-
dhat::assert_eq!(stats.max_bytes, 17024);
48+
if cfg!(any(miri, feature = "nightly")) {
49+
dhat::assert_eq!(stats.max_bytes, 18088);
50+
} else {
51+
dhat::assert_eq!(stats.max_bytes, 17024);
52+
}
4953

5054
let num_keys = KEY_LEVEL_WIDTH
5155
.iter()

tests/memory_usage_large_prefixes.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ fn test_memory_usage() {
5959
dhat::assert_eq!(stats.curr_bytes, 0);
6060

6161
dhat::assert_eq!(stats.max_blocks, 360);
62-
dhat::assert_eq!(stats.max_bytes, 17225);
62+
if cfg!(any(miri, feature = "nightly")) {
63+
dhat::assert_eq!(stats.max_bytes, 17681);
64+
} else {
65+
dhat::assert_eq!(stats.max_bytes, 17225);
66+
}
6367

6468
let num_keys = KEY_LEVEL_WIDTH
6569
.iter()

tests/memory_usage_skewed.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ fn test_memory_usage() {
4646
dhat::assert_eq!(stats.curr_bytes, 0);
4747

4848
dhat::assert_eq!(stats.max_blocks, 511);
49-
dhat::assert_eq!(stats.max_bytes, 25170);
49+
if cfg!(any(miri, feature = "nightly")) {
50+
dhat::assert_eq!(stats.max_bytes, 27202);
51+
} else {
52+
dhat::assert_eq!(stats.max_bytes, 25170);
53+
}
5054

5155
let mean_blocks_per_key = (stats.max_blocks as f64) / (KEY_LENGTH_LIMIT as f64);
5256
let mean_bytes_per_key = (stats.max_bytes as f64) / (KEY_LENGTH_LIMIT as f64);

0 commit comments

Comments
 (0)