[HiCache] Publish a host store event for storage-prefetch refills (#38486)
Co-authored-by: Shuwen Wang <47200617+alphabetc1@users.noreply.github.com>
This commit is contained in:
co-authored by
Shuwen Wang
parent
a7cf4a6fbc
commit
7078e5ffbc
@@ -3634,6 +3634,40 @@ fn insert_host_attaches_a_host_only_leaf_under_the_root() {
|
||||
tc.sanity_check(&[], &[]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insert_host_publishes_a_host_store_event() {
|
||||
// A storage-prefetch refill has no write-through ack to publish it.
|
||||
let mut tc = events_core(2);
|
||||
let root = tc.arena.root();
|
||||
let key = vec![1i64, 2, 7, 8];
|
||||
let hashes = crate::node::get_hash_str::<Vec<i64>>(&key, None, 2);
|
||||
let result = tc
|
||||
.insert_host(
|
||||
tc.arena.node(root).id,
|
||||
/* extra_key = */ None,
|
||||
key.clone(),
|
||||
Tensor::from_slice(&[100i64, 101, 102, 103]),
|
||||
hashes.clone(),
|
||||
)
|
||||
.expect("live test node");
|
||||
assert!(!result.host_insert_dropped);
|
||||
assert!(result.inserted_host_node.is_some());
|
||||
assert_eq!(
|
||||
tc.take_events(),
|
||||
vec![KvCacheEvent::BlockStored {
|
||||
block_hashes: hashes
|
||||
.iter()
|
||||
.map(|hash| crate::node::hash_str_to_int64(hash))
|
||||
.collect(),
|
||||
parent_block_hash: None,
|
||||
token_ids: key,
|
||||
block_size: 2,
|
||||
medium: StorageMedium::Cpu,
|
||||
cache_salt: None,
|
||||
}]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn insert_host_allows_a_suffix_under_an_unbacked_write_back_parent() {
|
||||
let mut tc = core();
|
||||
|
||||
@@ -3107,6 +3107,7 @@ impl<K: ChildKeyType> UnifiedTreeCore<K> {
|
||||
self.update_evictable_leaf_sets_(new_node_id);
|
||||
self.update_evictable_leaf_sets_(node_id);
|
||||
result.inserted_host_node = Some(self.arena.node(new_node_id).id);
|
||||
self.record_store_event_(new_node_id, StorageMedium::Cpu);
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user