Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation for 32-bit architectures on nightly #300

Merged
merged 4 commits into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ matrix:
env:
- TEST=crash
- RUST_BACKTRACE=1
- rust: nightly-2018-01-02
env:
- TEST=cross-build
- TARGET=i686-unknown-linux-gnu

install:
- curl https://sh.rustup.rs -sSf |
sh -s -- -y --default-toolchain $TRAVIS_RUST_VERSION
- if [ -n "$TARGET" ]; then
rustup target add $TARGET;
fi
- source ~/.cargo/env

script:
- bash -c 'case "$TEST" in
Expand All @@ -38,6 +50,11 @@ script:
crash)
cargo test test_crash_recovery --release --features="check_snapshot_integrity" -- --nocapture
;;
cross-build)
echo "https://github.com/rust-lang/cargo/issues/4753";
pushd crates/sled; cargo build --target $TARGET --features=nightly; popd;
pushd crates/pagecache; cargo build --target $TARGET --features=nightly; popd
;;
*)
cargo check;
cargo check --features=all;
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ assert_eq!(tree.get(&k), Ok(Some(vec![4])));
operations per second with mixed workloads, and 7 million/s
for read-only workloads on tiny keys. this will be improving
dramatically soon!
* 32 bit architectures [require Rust nightly with the `nightly` feature enabled](https://github.com/spacejam/sled/issues/145).

# contribution welcome!

Expand Down
1 change: 1 addition & 0 deletions crates/pagecache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ lock_free_delays = ["rand"]
failpoints = ["fail"]
no_metrics = ["historian/bypass"]
no_logs = ["log/max_level_off"]
nightly = []

[dependencies.historian]
version = "3.0"
Expand Down
20 changes: 15 additions & 5 deletions crates/pagecache/src/io/iobuf.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use std::sync::{Condvar, Mutex};
use std::sync::atomic::{AtomicBool, AtomicIsize, AtomicUsize};
use std::sync::atomic::{AtomicBool, AtomicUsize};
#[cfg(target_pointer_width = "32")]
use std::sync::atomic::AtomicI64;
#[cfg(target_pointer_width = "64")]
use std::sync::atomic::AtomicIsize;
use std::sync::atomic::Ordering::SeqCst;

#[cfg(feature = "failpoints")]
Expand All @@ -13,6 +17,10 @@ use self::reader::LogReader;
use super::*;

type Header = u64;
#[cfg(target_pointer_width = "64")]
type AtomicLsn = AtomicIsize;
#[cfg(target_pointer_width = "32")]
type AtomicLsn = AtomicI64;

macro_rules! io_fail {
($self:expr, $e:expr) => {
Expand Down Expand Up @@ -52,8 +60,8 @@ pub(super) struct IoBufs {
// stable storage. This may be lower than the length of the underlying
// file, and there may be buffers that have been written out-of-order
// to stable storage due to interesting thread interleavings.
stable_lsn: AtomicIsize,
max_reserved_lsn: AtomicIsize,
stable_lsn: AtomicLsn,
max_reserved_lsn: AtomicLsn,
segment_accountant: Mutex<SegmentAccountant>,

// used for signifying that we're simulating a crash
Expand Down Expand Up @@ -166,8 +174,8 @@ impl IoBufs {
written_bufs: AtomicUsize::new(0),
intervals: Mutex::new(vec![]),
interval_updated: Condvar::new(),
stable_lsn: AtomicIsize::new(stable),
max_reserved_lsn: AtomicIsize::new(stable),
stable_lsn: AtomicLsn::new(stable),
max_reserved_lsn: AtomicLsn::new(stable),
config: config,
segment_accountant: Mutex::new(segment_accountant),
#[cfg(feature = "failpoints")]
Expand Down Expand Up @@ -259,6 +267,8 @@ impl IoBufs {

let io_bufs = self.config.io_bufs;

// right shift 32 on 32-bit pointer systems panics
#[cfg(target_pointer_width = "64")]
assert_eq!((raw_buf.len() + MSG_HEADER_LEN) >> 32, 0);

let buf = self.encapsulate(raw_buf);
Expand Down
3 changes: 3 additions & 0 deletions crates/pagecache/src/io/segment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,9 @@ pub fn raw_segment_iter_from(

Ok(LogIter {
config: config.clone(),
#[cfg(feature = "nightly")]
max_lsn: std::i64::MAX,
#[cfg(not(feature = "nightly"))]
max_lsn: std::isize::MAX,
cur_lsn: SEG_HEADER_LEN as Lsn,
segment_base: None,
Expand Down
8 changes: 8 additions & 0 deletions crates/pagecache/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#![cfg_attr(feature="clippy", feature(plugin))]
#![cfg_attr(feature="clippy", plugin(clippy))]
#![cfg_attr(feature="clippy", allow(inline_always))]
#![cfg_attr(feature="nightly", feature(integer_atomics))]
#[cfg(all(not(feature="nightly"), target_pointer_width = "32"))]
compile_error!("32 bit architectures require a nightly compiler for now.
See https://github.com/spacejam/sled/issues/145");

#[macro_use]
extern crate serde_derive;
Expand Down Expand Up @@ -75,6 +79,10 @@ pub type SegmentID = usize;
pub type LogID = u64;

/// A logical sequence number.
#[cfg(target_pointer_width = "32")]
pub type Lsn = i64;
/// A logical sequence number.
#[cfg(target_pointer_width = "64")]
pub type Lsn = isize;

/// A page identifier.
Expand Down
1 change: 1 addition & 0 deletions crates/sled/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ check_snapshot_integrity = []
no_logs = ["log/max_level_off", "pagecache/no_logs"]
rayon = ["pagecache/rayon"]
zstd = ["pagecache/zstd"]
nightly = ["pagecache/nightly"]

[profile.release]
debug = 2
Expand Down