Skip to content

Commit

Permalink
0.9.0
Browse files Browse the repository at this point in the history
- Make file-backed memmap `SkipMap` and `SkipSet` still can be reopened even the last time the program was aborted.
- Remove checksum validation. Users should take care of data integrity by themselves.
- Support `Clone` directly; no need to use the `Arc` wrapper anymore.
- Add `OpenOptions` and `MmapOptions` to support better controls on file memmap backed `SkipMap` and `SkipSet`.
  • Loading branch information
al8n committed May 15, 2024
1 parent cc406fa commit 168011d
Show file tree
Hide file tree
Showing 18 changed files with 1,584 additions and 479 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## 0.9.0

- Make file backed mmap `SkipMap` and `SkipSet` still can be reopened even last time the program was aborted.
- Remove checksum validation, users should take care of data integrity by themselves.
- Support `Clone` directly, no need to use `Arc` wrapper anymore.
- Add `OpenOptions` and `MmapOptions` to support better controls on file mmap backed `SkipMap` and `SkipSet`.

## 0.8.6

- Add `SkipMap::min_version` and `SkipSet::min_version` to access the min version of the `SkipMap` or `SkipSet`.
Expand Down
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "skl"
version = "0.8.6"
version = "0.9.0"
edition = "2021"
rust-version = "1.56.0"
repository = "https://github.com/al8n/skl-rs"
Expand Down Expand Up @@ -33,7 +33,7 @@ required-features = ["memmap"]
[features]
default = ["std"]
alloc = []
memmap = ["memmap2", "fs4", "std", "crc32fast"]
memmap = ["memmap2", "fs4", "std"]
std = ["rand/default", "either/default"]

[target.'cfg(loom)'.dependencies]
Expand All @@ -49,7 +49,6 @@ rand = { version = "0.8", default-features = false, features = ["getrandom"] }

fs4 = { version = "0.8", optional = true }
memmap2 = { version = "0.9", optional = true }
crc32fast = { version = "1", optional = true }

[dev-dependencies]
criterion = "0.5"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@

```toml
[dependencies]
skl = "0.8"
skl = "0.9"
```

- Enable memory map backend

```toml
[dependencies]
skl = { version = "0.8", features = ["memmap"] }
skl = { version = "0.9", features = ["memmap"] }
```

## Features
Expand Down
8 changes: 7 additions & 1 deletion examples/mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ pub fn new_value(i: usize) -> Vec<u8> {
fn main() {
const N: usize = 1000;

let l = Arc::new(SkipMap::mmap_mut("test.wal", 1 << 20, true).unwrap());
let mmap_options = skl::MmapOptions::default();
let open_options = skl::OpenOptions::default()
.create_new(Some(1 << 20))
.read(true)
.write(true);

let l = Arc::new(SkipMap::mmap_mut("test.wal", open_options, mmap_options).unwrap());
let wg = Arc::new(());
for i in 0..N {
let w = wg.clone();
Expand Down
4 changes: 3 additions & 1 deletion examples/mmap_anon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ pub fn new_value(i: usize) -> Vec<u8> {

fn main() {
const N: usize = 1000;
let l = Arc::new(SkipMap::mmap_anon(1 << 20).unwrap());

let mmap_options = skl::MmapOptions::default().len(1 << 20);
let l = Arc::new(SkipMap::mmap_anon(mmap_options).unwrap());
let wg = Arc::new(());
for i in 0..N {
let w = wg.clone();
Expand Down
8 changes: 6 additions & 2 deletions integration/src/bin/test-mmap-anon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ use std::sync::Arc;
fn main() {
{
const N: usize = 10;
let l = Arc::new(SkipMap::mmap_anon(1 << 20).unwrap());

let mmap_options = MmapOptions::default().len(1 << 20);
let l = Arc::new(SkipMap::mmap_anon(mmap_options).unwrap());
for i in 0..N {
let l = l.clone();
std::thread::spawn(move || {
Expand All @@ -27,7 +29,9 @@ fn main() {

{
const N2: usize = 100;
let l = Arc::new(SkipMap::mmap_anon(120 << 20).unwrap());

let mmap_options = MmapOptions::default().len(120 << 20);
let l = Arc::new(SkipMap::mmap_anon(mmap_options).unwrap());
for i in 0..N2 {
let l = l.clone();
std::thread::spawn(move || {
Expand Down
13 changes: 11 additions & 2 deletions integration/src/bin/test-mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ fn main() {
let p = dir.path().join("test_mmap");
{
const N: usize = 10;
let l = Arc::new(SkipMap::mmap_mut(&p, 1 << 20, true).unwrap());

let open_options = OpenOptions::default()
.create_new(Some(1 << 20))
.read(true)
.write(true);
let mmap_options = MmapOptions::default();
let l = Arc::new(SkipMap::mmap_mut(&p, open_options, mmap_options).unwrap());
for i in 0..N {
let l = l.clone();
std::thread::spawn(move || {
Expand All @@ -29,7 +35,10 @@ fn main() {

{
const N2: usize = 10;
let l = Arc::new(SkipMap::<u64>::mmap(&p, false).unwrap());

let open_options = OpenOptions::default().read(true);
let mmap_options = MmapOptions::default();
let l = Arc::new(SkipMap::<u64>::mmap(&p, open_options, mmap_options).unwrap());
assert_eq!(N2, l.len());
for i in 0..N2 {
let l = l.clone();
Expand Down
Loading

0 comments on commit 168011d

Please sign in to comment.