Fixes and ensures 32bits x86 support

pull/717/head
Tpt 12 months ago committed by Thomas Tanon
parent a5781d1187
commit 391e8d7662
  1. 2
      .github/workflows/artifacts.yml
  2. 15
      .github/workflows/tests.yml
  3. 7
      lib/src/storage/backend/rocksdb.rs
  4. 32
      lib/src/storage/mod.rs
  5. 10
      oxrocksdb-sys/build.rs

@ -24,7 +24,7 @@ jobs:
with: with:
target: aarch64-unknown-linux-gnu target: aarch64-unknown-linux-gnu
- run: | - run: |
sudo apt update && sudo apt-get install -y g++-aarch64-linux-gnu sudo apt-get install -y g++-aarch64-linux-gnu
mkdir .cargo mkdir .cargo
echo -e "[target.aarch64-unknown-linux-gnu]\nlinker = \"aarch64-linux-gnu-gcc\"" >> .cargo/config.toml echo -e "[target.aarch64-unknown-linux-gnu]\nlinker = \"aarch64-linux-gnu-gcc\"" >> .cargo/config.toml
- run: cargo build --release --no-default-features --features rustls-native - run: cargo build --release --no-default-features --features rustls-native

@ -118,7 +118,7 @@ jobs:
- run: cargo install cargo-semver-checks || true - run: cargo install cargo-semver-checks || true
- run: cargo semver-checks check-release --exclude oxrocksdb-sys --exclude oxigraph-js --exclude pyoxigraph --exclude oxigraph-testsuite --exclude oxigraph-cli - run: cargo semver-checks check-release --exclude oxrocksdb-sys --exclude oxigraph-js --exclude pyoxigraph --exclude oxigraph-testsuite --exclude oxigraph-cli
test_linux: test_linux_x86_64:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -127,6 +127,19 @@ jobs:
- uses: ./.github/actions/setup-rust - uses: ./.github/actions/setup-rust
- run: cargo test - run: cargo test
test_linux_i686:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: ./.github/actions/setup-rust
with:
target: i686-unknown-linux-gnu
- run: sudo apt-get install -y g++-multilib
- run: cargo test --target i686-unknown-linux-gnu --no-default-features --features http-client-rustls-native
working-directory: ./lib
test_linux_msv: test_linux_msv:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

@ -13,6 +13,7 @@ use libc::{self, c_void, free};
use oxrocksdb_sys::*; use oxrocksdb_sys::*;
use rand::random; use rand::random;
use std::borrow::Borrow; use std::borrow::Borrow;
#[cfg(unix)]
use std::cmp::min; use std::cmp::min;
use std::collections::HashMap; use std::collections::HashMap;
use std::env::temp_dir; use std::env::temp_dir;
@ -1405,7 +1406,7 @@ fn path_to_cstring(path: &Path) -> Result<CString, StorageError> {
} }
#[cfg(unix)] #[cfg(unix)]
fn available_file_descriptors() -> io::Result<Option<u64>> { fn available_file_descriptors() -> io::Result<Option<libc::rlim_t>> {
let mut rlimit = libc::rlimit { let mut rlimit = libc::rlimit {
rlim_cur: 0, rlim_cur: 0,
rlim_max: 0, rlim_max: 0,
@ -1418,12 +1419,12 @@ fn available_file_descriptors() -> io::Result<Option<u64>> {
} }
#[cfg(windows)] #[cfg(windows)]
fn available_file_descriptors() -> io::Result<Option<u64>> { fn available_file_descriptors() -> io::Result<Option<libc::c_int>> {
Ok(Some(512)) // https://docs.microsoft.com/en-us/cpp/c-runtime-library/file-handling Ok(Some(512)) // https://docs.microsoft.com/en-us/cpp/c-runtime-library/file-handling
} }
#[cfg(not(any(unix, windows)))] #[cfg(not(any(unix, windows)))]
fn available_file_descriptors() -> io::Result<Option<u64>> { fn available_file_descriptors() -> io::Result<Option<libc::c_int>> {
Ok(None) Ok(None)
} }

@ -26,7 +26,7 @@ use std::mem::{swap, take};
#[cfg(not(target_family = "wasm"))] #[cfg(not(target_family = "wasm"))]
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
#[cfg(not(target_family = "wasm"))] #[cfg(not(target_family = "wasm"))]
use std::sync::atomic::{AtomicU64, Ordering}; use std::sync::Mutex;
#[cfg(not(target_family = "wasm"))] #[cfg(not(target_family = "wasm"))]
use std::{io, thread}; use std::{io, thread};
@ -1249,7 +1249,7 @@ impl StorageBulkLoader {
) )
.into()); .into());
} }
let done_counter = AtomicU64::new(0); let done_counter = Mutex::new(0);
let mut done_and_displayed_counter = 0; let mut done_and_displayed_counter = 0;
thread::scope(|thread_scope| { thread::scope(|thread_scope| {
let mut threads = VecDeque::with_capacity(num_threads - 1); let mut threads = VecDeque::with_capacity(num_threads - 1);
@ -1280,7 +1280,7 @@ impl StorageBulkLoader {
)?; )?;
for thread in threads { for thread in threads {
map_thread_result(thread.join()).map_err(StorageError::Io)??; map_thread_result(thread.join()).map_err(StorageError::Io)??;
self.on_possible_progress(&done_counter, &mut done_and_displayed_counter); self.on_possible_progress(&done_counter, &mut done_and_displayed_counter)?;
} }
Ok(()) Ok(())
}) })
@ -1291,17 +1291,17 @@ impl StorageBulkLoader {
buffer: &mut Vec<Quad>, buffer: &mut Vec<Quad>,
threads: &mut VecDeque<thread::ScopedJoinHandle<'scope, Result<(), StorageError>>>, threads: &mut VecDeque<thread::ScopedJoinHandle<'scope, Result<(), StorageError>>>,
thread_scope: &'scope thread::Scope<'scope, '_>, thread_scope: &'scope thread::Scope<'scope, '_>,
done_counter: &'scope AtomicU64, done_counter: &'scope Mutex<u64>,
done_and_displayed_counter: &mut u64, done_and_displayed_counter: &mut u64,
num_threads: usize, num_threads: usize,
batch_size: usize, batch_size: usize,
) -> Result<(), StorageError> { ) -> Result<(), StorageError> {
self.on_possible_progress(done_counter, done_and_displayed_counter); self.on_possible_progress(done_counter, done_and_displayed_counter)?;
// We avoid to have too many threads // We avoid to have too many threads
if threads.len() >= num_threads { if threads.len() >= num_threads {
if let Some(thread) = threads.pop_front() { if let Some(thread) = threads.pop_front() {
map_thread_result(thread.join()).map_err(StorageError::Io)??; map_thread_result(thread.join()).map_err(StorageError::Io)??;
self.on_possible_progress(done_counter, done_and_displayed_counter); self.on_possible_progress(done_counter, done_and_displayed_counter)?;
} }
} }
let mut buffer_to_load = Vec::with_capacity(batch_size); let mut buffer_to_load = Vec::with_capacity(batch_size);
@ -1313,15 +1313,22 @@ impl StorageBulkLoader {
Ok(()) Ok(())
} }
fn on_possible_progress(&self, done: &AtomicU64, done_and_displayed: &mut u64) { fn on_possible_progress(
let new_counter = done.load(Ordering::Relaxed); &self,
let display_step = u64::try_from(DEFAULT_BULK_LOAD_BATCH_SIZE).unwrap(); done: &Mutex<u64>,
done_and_displayed: &mut u64,
) -> Result<(), StorageError> {
let new_counter = *done
.lock()
.map_err(|_| io::Error::new(io::ErrorKind::Other, "Mutex poisoned"))?;
let display_step = DEFAULT_BULK_LOAD_BATCH_SIZE as u64;
if new_counter / display_step > *done_and_displayed / display_step { if new_counter / display_step > *done_and_displayed / display_step {
for hook in &self.hooks { for hook in &self.hooks {
hook(new_counter); hook(new_counter);
} }
} }
*done_and_displayed = new_counter; *done_and_displayed = new_counter;
Ok(())
} }
} }
@ -1346,11 +1353,14 @@ impl<'a> FileBulkLoader<'a> {
} }
} }
fn load(&mut self, quads: Vec<Quad>, counter: &AtomicU64) -> Result<(), StorageError> { fn load(&mut self, quads: Vec<Quad>, counter: &Mutex<u64>) -> Result<(), StorageError> {
self.encode(quads)?; self.encode(quads)?;
let size = self.triples.len() + self.quads.len(); let size = self.triples.len() + self.quads.len();
self.save()?; self.save()?;
counter.fetch_add(size.try_into().unwrap_or(u64::MAX), Ordering::Relaxed); *counter
.lock()
.map_err(|_| io::Error::new(io::ErrorKind::Other, "Mutex poisoned"))? +=
size.try_into().unwrap_or(u64::MAX);
Ok(()) Ok(())
} }

@ -153,7 +153,7 @@ fn build_rocksdb() {
config.define("NOMINMAX", None); config.define("NOMINMAX", None);
config.define("ROCKSDB_WINDOWS_UTF8_FILENAMES", None); config.define("ROCKSDB_WINDOWS_UTF8_FILENAMES", None);
if target == "x86_64-pc-windows-gnu" { if target.contains("pc-windows-gnu") {
// Tell MinGW to create localtime_r wrapper of localtime_s function. // Tell MinGW to create localtime_r wrapper of localtime_s function.
config.define("_POSIX_C_SOURCE", Some("1")); config.define("_POSIX_C_SOURCE", Some("1"));
// Tell MinGW to use at least Windows Vista headers instead of the ones of Windows XP. // Tell MinGW to use at least Windows Vista headers instead of the ones of Windows XP.
@ -193,10 +193,10 @@ fn build_rocksdb() {
if target.contains("msvc") { if target.contains("msvc") {
config.flag("-EHsc").flag("-std:c++17"); config.flag("-EHsc").flag("-std:c++17");
} else { } else {
config config.flag("-std=c++17").flag("-Wno-invalid-offsetof");
.flag("-std=c++17") if target.contains("x86_64") || target.contains("aarch64") {
.flag("-Wno-invalid-offsetof") config.define("HAVE_UINT128_EXTENSION", Some("1"));
.define("HAVE_UINT128_EXTENSION", Some("1")); }
} }
for file in lib_sources { for file in lib_sources {

Loading…
Cancel
Save