Skip to content

Commit

Permalink
Prevent inconsistencies between concurrent hash table and policy
Browse files Browse the repository at this point in the history
data structures caused by timing issues

Fix a test for Linux 32-bit platforms.
  • Loading branch information
tatsuya6502 committed Nov 19, 2023
1 parent 6f1d683 commit a28970c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
24 changes: 18 additions & 6 deletions src/common/concurrent/entry_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,9 @@ mod test {
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
enum TargetArch {
Linux64,
Linux32,
Linux32X86,
Linux32Arm,
Linux32Mips,
MacOS64,
}

Expand All @@ -184,9 +186,17 @@ mod test {
if cfg!(target_pointer_width = "64") {
Linux64
} else if cfg!(target_pointer_width = "32") {
Linux32
if cfg!(target_arch = "x86") {
Linux32X86
} else if cfg!(target_arch = "arm") {
Linux32Arm
} else if cfg!(target_arch = "x86") {

Check failure on line 193 in src/common/concurrent/entry_info.rs

View workflow job for this annotation

GitHub Actions / clippy

this `if` has the same condition as a previous `if`

error: this `if` has the same condition as a previous `if` --> src/common/concurrent/entry_info.rs:193:27 | 193 | } else if cfg!(target_arch = "x86") { | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: same as this --> src/common/concurrent/entry_info.rs:189:20 | 189 | if cfg!(target_arch = "x86") { | ^^^^^^^^^^^^^^^^^^^^^^^^^ = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ifs_same_cond = note: `-D clippy::ifs-same-cond` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::ifs_same_cond)]` = note: this error originates in the macro `cfg` (in Nightly builds, run with -Z macro-backtrace for more info)
Linux32Mips
} else {
unimplemented!();
}
} else {
panic!("Unsupported pointer width for Linux");
unimplemented!();
}
} else if cfg!(target_os = "macos") {
MacOS64
Expand All @@ -195,11 +205,13 @@ mod test {
};

let expected_sizes = match (arch, is_quanta_enabled) {
(Linux64, true) => vec![("1.51", 56)],
(Linux32, true) => vec![("1.51", 56)],
(Linux64 | Linux32Arm, true) => vec![("1.51", 56)],
(Linux32X86, true) => vec![("1.51", 48)],
(Linux32Mips, true) => unimplemented!(),
(MacOS64, true) => vec![("1.62", 56)],
(Linux64, false) => vec![("1.66", 104), ("1.60", 128)],
(Linux32, false) => vec![("1.66", 96), ("1.62", 120), ("1.60", 72)],
(Linux32X86, false) => unimplemented!(),
(Linux32Arm | Linux32Mips, false) => vec![("1.66", 104), ("1.62", 128), ("1.60", 80)],
(MacOS64, false) => vec![("1.62", 104)],
};

Expand Down
6 changes: 3 additions & 3 deletions src/future/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3080,9 +3080,9 @@ mod tests {
// The following `insert` will do the followings:
// 1. Replaces current "c" (c1) in the concurrent hash table (cht).
// 2. Runs the pending tasks implicitly.
// (1) c1 will be evicted by size constraint.
// (2) "a" will be admitted.
// (3) "b" will be admitted.
// (1) "a" will be admitted.
// (2) "b" will be admitted.
// (3) c1 will be evicted by size constraint.
// (4) "a" will be evicted due to expiration.
// (5) "b" will be evicted due to expiration.
// 3. Send its `WriteOp` log to the channel.
Expand Down
6 changes: 3 additions & 3 deletions src/sync/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2736,9 +2736,9 @@ mod tests {
// The following `insert` will do the followings:
// 1. Replaces current "c" (c1) in the concurrent hash table (cht).
// 2. Runs the pending tasks implicitly.
// (1) c1 will be evicted by size constraint.
// (2) "a" will be admitted.
// (3) "b" will be admitted.
// (1) "a" will be admitted.
// (2) "b" will be admitted.
// (3) c1 will be evicted by size constraint.
// (4) "a" will be evicted due to expiration.
// (5) "b" will be evicted due to expiration.
// 3. Send its `WriteOp` log to the channel.
Expand Down

0 comments on commit a28970c

Please sign in to comment.