Single threaded rodeo

This commit is contained in:
Antoine Gersant 2024-08-09 12:11:25 -07:00
parent a4baa2c792
commit 763ba94e9b
6 changed files with 14 additions and 28 deletions

14
Cargo.lock generated
View file

@ -526,19 +526,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "dashmap"
version = "5.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"
dependencies = [
"cfg-if",
"hashbrown",
"lock_api",
"once_cell",
"parking_lot_core",
]
[[package]] [[package]]
name = "der" name = "der"
version = "0.7.9" version = "0.7.9"
@ -1127,7 +1114,6 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a030549b8dfea08d7981ad0381acb4bc0cdc7a4fd616e3b9659c31dc0a3474fd" checksum = "a030549b8dfea08d7981ad0381acb4bc0cdc7a4fd616e3b9659c31dc0a3474fd"
dependencies = [ dependencies = [
"dashmap",
"hashbrown", "hashbrown",
"serde", "serde",
] ]

View file

@ -19,7 +19,7 @@ getopts = "0.2.21"
headers = "0.4" headers = "0.4"
http = "1.1.0" http = "1.1.0"
id3 = "1.14.0" id3 = "1.14.0"
lasso2 = { version = "0.8.2", features = ["multi-threaded", "serialize"] } lasso2 = { version = "0.8.2", features = ["serialize"] }
lewton = "0.10.2" lewton = "0.10.2"
log = "0.4.22" log = "0.4.22"
metaflac = "0.2.7" metaflac = "0.2.7"

View file

@ -3,7 +3,7 @@ use std::{
sync::{Arc, RwLock}, sync::{Arc, RwLock},
}; };
use lasso2::{RodeoReader, ThreadedRodeo}; use lasso2::{Rodeo, RodeoReader};
use log::{error, info}; use log::{error, info};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tokio::task::spawn_blocking; use tokio::task::spawn_blocking;
@ -210,7 +210,7 @@ pub struct Index {
impl Default for Index { impl Default for Index {
fn default() -> Self { fn default() -> Self {
Self { Self {
strings: ThreadedRodeo::new().into_reader(), strings: Rodeo::new().into_reader(),
browser: Default::default(), browser: Default::default(),
collection: Default::default(), collection: Default::default(),
} }
@ -218,7 +218,7 @@ impl Default for Index {
} }
pub struct Builder { pub struct Builder {
strings: ThreadedRodeo, strings: Rodeo,
browser_builder: browser::Builder, browser_builder: browser::Builder,
collection_builder: collection::Builder, collection_builder: collection::Builder,
} }
@ -226,7 +226,7 @@ pub struct Builder {
impl Builder { impl Builder {
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
strings: ThreadedRodeo::new(), strings: Rodeo::new(),
browser_builder: browser::Builder::default(), browser_builder: browser::Builder::default(),
collection_builder: collection::Builder::default(), collection_builder: collection::Builder::default(),
} }

View file

@ -5,7 +5,7 @@ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
use lasso2::{RodeoReader, ThreadedRodeo}; use lasso2::{Rodeo, RodeoReader};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tinyvec::TinyVec; use tinyvec::TinyVec;
use trie_rs::{Trie, TrieBuilder}; use trie_rs::{Trie, TrieBuilder};
@ -105,7 +105,7 @@ pub struct Builder {
} }
impl Builder { impl Builder {
pub fn add_directory(&mut self, strings: &mut ThreadedRodeo, directory: scanner::Directory) { pub fn add_directory(&mut self, strings: &mut Rodeo, directory: scanner::Directory) {
let Some(virtual_path) = directory.virtual_path.get_or_intern(strings) else { let Some(virtual_path) = directory.virtual_path.get_or_intern(strings) else {
return; return;
}; };
@ -125,7 +125,7 @@ impl Builder {
.insert(storage::File::Directory(virtual_path)); .insert(storage::File::Directory(virtual_path));
} }
pub fn add_song(&mut self, strings: &mut ThreadedRodeo, song: &scanner::Song) { pub fn add_song(&mut self, strings: &mut Rodeo, song: &scanner::Song) {
let Some(virtual_path) = (&song.virtual_path).get_or_intern(strings) else { let Some(virtual_path) = (&song.virtual_path).get_or_intern(strings) else {
return; return;
}; };

View file

@ -4,7 +4,7 @@ use std::{
path::PathBuf, path::PathBuf,
}; };
use lasso2::{RodeoReader, ThreadedRodeo}; use lasso2::{RodeoReader, Rodeo};
use rand::{rngs::ThreadRng, seq::IteratorRandom}; use rand::{rngs::ThreadRng, seq::IteratorRandom};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -160,7 +160,7 @@ pub struct Builder {
} }
impl Builder { impl Builder {
pub fn add_song(&mut self, strings: &mut ThreadedRodeo, song: &scanner::Song) { pub fn add_song(&mut self, strings: &mut Rodeo, song: &scanner::Song) {
let Some(song) = store_song(strings, song) else { let Some(song) = store_song(strings, song) else {
return; return;
}; };

View file

@ -3,7 +3,7 @@ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
}; };
use lasso2::{RodeoReader, ThreadedRodeo}; use lasso2::{RodeoReader, Rodeo};
use log::error; use log::error;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use tinyvec::TinyVec; use tinyvec::TinyVec;
@ -87,7 +87,7 @@ impl Song {
} }
} }
pub fn store_song(strings: &mut ThreadedRodeo, song: &scanner::Song) -> Option<Song> { pub fn store_song(strings: &mut Rodeo, song: &scanner::Song) -> Option<Song> {
let Some(path) = (&song.path).get_or_intern(strings) else { let Some(path) = (&song.path).get_or_intern(strings) else {
return None; return None;
}; };
@ -196,12 +196,12 @@ pub fn fetch_song(strings: &RodeoReader, song: &Song) -> super::Song {
} }
pub trait InternPath { pub trait InternPath {
fn get_or_intern(self, strings: &mut ThreadedRodeo) -> Option<PathKey>; fn get_or_intern(self, strings: &mut Rodeo) -> Option<PathKey>;
fn get(self, strings: &RodeoReader) -> Option<PathKey>; fn get(self, strings: &RodeoReader) -> Option<PathKey>;
} }
impl<P: AsRef<Path>> InternPath for P { impl<P: AsRef<Path>> InternPath for P {
fn get_or_intern(self, strings: &mut ThreadedRodeo) -> Option<PathKey> { fn get_or_intern(self, strings: &mut Rodeo) -> Option<PathKey> {
let id = self let id = self
.as_ref() .as_ref()
.as_os_str() .as_os_str()