S3-FIFO caching

This commit is contained in:
mdecimus
2024-12-27 19:40:33 +01:00
parent 3530b6625f
commit f2b00ccd54
33 changed files with 631 additions and 383 deletions

View File

@@ -5,6 +5,7 @@ edition = "2021"
resolver = "2"
[dependencies]
utils = { path = "../utils" }
xxhash-rust = { version = "0.8.5", features = ["xxh3"] }
farmhash = "1.1.5"
siphasher = "1.0"

View File

@@ -7,6 +7,7 @@
use ahash::AHashMap;
use radix_trie::TrieKey;
use serde::{Deserialize, Serialize};
use utils::cache::CacheItemWeight;
use crate::tokenizers::osb::Gram;
@@ -142,6 +143,18 @@ impl From<Weights> for i64 {
}
}
impl CacheItemWeight for Weights {
fn weight(&self) -> u64 {
std::mem::size_of::<u64>() as u64
}
}
impl CacheItemWeight for TokenHash {
fn weight(&self) -> u64 {
self.len as u64
}
}
impl TokenHash {
pub fn serialize_index(prefix: u8, account_id: Option<u32>) -> Vec<u8> {
if let Some(account_id) = account_id {