graph: use index for bulk reads, skip capnp deserialization
- Add all_keys() to StoreView, use in build_adjacency instead of for_each_node (which was ignoring content/weight anyway) - Add all_key_uuid_pairs() for single-pass uuid mapping - Extend KEY_TO_UUID to store [uuid:16][node_type:1][timestamp:8] - for_each_node_meta now reads from index, no capnp needed - Add NodeType::from_u8() for unpacking Graph health: 7s → 2s (3.5x faster) Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
b3d0a3ab25
commit
faad14dc95
6 changed files with 103 additions and 40 deletions
|
|
@ -24,7 +24,7 @@ impl Store {
|
|||
let db = self.db.as_ref().ok_or_else(|| anyhow!("store not loaded"))?;
|
||||
let txn = db.begin_write()?;
|
||||
let offset = self.append_nodes(&[node.clone()])?;
|
||||
index::index_node(&txn, &node.key, offset, &node.uuid)?;
|
||||
index::index_node(&txn, &node.key, offset, &node.uuid, node.node_type as u8, node.timestamp)?;
|
||||
txn.commit()?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ impl Store {
|
|||
node.version += 1;
|
||||
let txn = db.begin_write()?;
|
||||
let offset = self.append_nodes(std::slice::from_ref(&node))?;
|
||||
index::index_node(&txn, &node.key, offset, &node.uuid)?;
|
||||
index::index_node(&txn, &node.key, offset, &node.uuid, node.node_type as u8, node.timestamp)?;
|
||||
txn.commit()?;
|
||||
Ok("updated")
|
||||
} else {
|
||||
|
|
@ -98,7 +98,7 @@ impl Store {
|
|||
node.provenance = provenance.to_string();
|
||||
let txn = db.begin_write()?;
|
||||
let offset = self.append_nodes(std::slice::from_ref(&node))?;
|
||||
index::index_node(&txn, &node.key, offset, &node.uuid)?;
|
||||
index::index_node(&txn, &node.key, offset, &node.uuid, node.node_type as u8, node.timestamp)?;
|
||||
txn.commit()?;
|
||||
Ok("created")
|
||||
}
|
||||
|
|
@ -189,7 +189,7 @@ impl Store {
|
|||
let txn = db.begin_write()?;
|
||||
let offset = self.append_nodes(&[renamed.clone(), tombstone])?;
|
||||
index::remove_node(&txn, old_key)?;
|
||||
index::index_node(&txn, new_key, offset, &renamed.uuid)?;
|
||||
index::index_node(&txn, new_key, offset, &renamed.uuid, renamed.node_type as u8, renamed.timestamp)?;
|
||||
if !updated_rels.is_empty() {
|
||||
self.append_relations(&updated_rels)?;
|
||||
}
|
||||
|
|
@ -320,7 +320,7 @@ impl Store {
|
|||
node.timestamp = now_epoch();
|
||||
let txn = db.begin_write()?;
|
||||
let offset = self.append_nodes(std::slice::from_ref(&node))?;
|
||||
index::index_node(&txn, key, offset, &node.uuid)?;
|
||||
index::index_node(&txn, key, offset, &node.uuid, node.node_type as u8, node.timestamp)?;
|
||||
txn.commit()?;
|
||||
Ok((old, weight))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue