Skip to content

Commit 8f9c381

Browse files
committed
feat(search): add make slab-fs mmaped
To reduce memory consumption
1 parent 9f7d05b commit 8f9c381

File tree

17 files changed

+3310
-23
lines changed

17 files changed

+3310
-23
lines changed

Cargo.lock

Lines changed: 67 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ members = [
1010
"query-segmentation",
1111
"cardinal-syntax",
1212
"search-cancel",
13+
"slab-mmap",
1314
]
1415
exclude = ["cardinal"]

cardinal/package-lock.json

Lines changed: 10 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cardinal/src-tauri/Cargo.lock

Lines changed: 16 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

search-cache/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ query-segmentation = { path = "../query-segmentation" }
1212
search-cancel = { path = "../search-cancel" }
1313
zstd = { version = "0.13", features = ["zstdmt"] }
1414
serde = { version = "1", features = ["derive"] }
15-
slab = { version = "0.4", features = ["serde"] }
1615
anyhow = "1.0.97"
1716
memchr = "2.7"
1817
crossbeam-channel = "0.5.15"
@@ -28,6 +27,7 @@ hashbrown = { version = "0.16.0", features = ["serde"] }
2827
regex = "1"
2928
jiff = "0.2"
3029
rayon = "1.9"
30+
slab-mmap = { path = "../slab-mmap" }
3131

3232
[dev-dependencies]
3333
tempdir = "0.3"

search-cache/src/slab.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use serde::{Deserialize, Serialize};
2+
use slab_mmap::{Slab, SlabIter};
23

34
#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
45
#[repr(transparent)]
@@ -53,7 +54,7 @@ impl SlabIndex {
5354
#[derive(Debug, Serialize, Deserialize)]
5455
#[serde(transparent)]
5556
#[repr(transparent)]
56-
pub struct ThinSlab<T>(slab::Slab<T>);
57+
pub struct ThinSlab<T>(Slab<T>);
5758

5859
impl<T> Default for ThinSlab<T> {
5960
fn default() -> Self {
@@ -63,7 +64,7 @@ impl<T> Default for ThinSlab<T> {
6364

6465
impl<T> ThinSlab<T> {
6566
pub fn new() -> Self {
66-
Self(slab::Slab::new())
67+
Self(Slab::new())
6768
}
6869

6970
pub fn insert(&mut self, value: T) -> SlabIndex {
@@ -109,7 +110,7 @@ impl<T> std::ops::IndexMut<SlabIndex> for ThinSlab<T> {
109110
}
110111
}
111112

112-
pub struct ThinSlabIter<'a, T>(slab::Iter<'a, T>);
113+
pub struct ThinSlabIter<'a, T>(SlabIter<'a, T>);
113114

114115
impl<'a, T> Iterator for ThinSlabIter<'a, T> {
115116
type Item = (SlabIndex, &'a T);

0 commit comments

Comments
 (0)