(LedgerStore) Report RocksDB perf metrics for Protobuf Columns (#24065)
This PR enables the reporting of both RocksDB read and write perf metrics for ProtobufColumns, including TransactionStatus and Rewards.
This commit is contained in:
committed by
GitHub
parent
550ca7bf92
commit
4f0e887702
@ -2399,7 +2399,13 @@ where
|
|||||||
&self,
|
&self,
|
||||||
key: C::Index,
|
key: C::Index,
|
||||||
) -> Result<Option<C::Type>> {
|
) -> Result<Option<C::Type>> {
|
||||||
if let Some(serialized_value) = self.backend.get_cf(self.handle(), &C::key(key))? {
|
let is_perf_context_enabled = maybe_collect_perf_context();
|
||||||
|
let result = self.backend.get_cf(self.handle(), &C::key(key));
|
||||||
|
if is_perf_context_enabled {
|
||||||
|
report_read_perf_context(C::rocksdb_get_perf_metric_header(&self.column_options));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(serialized_value) = result? {
|
||||||
let value = match C::Type::decode(&serialized_value[..]) {
|
let value = match C::Type::decode(&serialized_value[..]) {
|
||||||
Ok(value) => value,
|
Ok(value) => value,
|
||||||
Err(_) => deserialize::<T>(&serialized_value)?.into(),
|
Err(_) => deserialize::<T>(&serialized_value)?.into(),
|
||||||
@ -2411,7 +2417,13 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_protobuf(&self, key: C::Index) -> Result<Option<C::Type>> {
|
pub fn get_protobuf(&self, key: C::Index) -> Result<Option<C::Type>> {
|
||||||
if let Some(serialized_value) = self.backend.get_cf(self.handle(), &C::key(key))? {
|
let is_perf_context_enabled = maybe_collect_perf_context();
|
||||||
|
let result = self.backend.get_cf(self.handle(), &C::key(key));
|
||||||
|
if is_perf_context_enabled {
|
||||||
|
report_read_perf_context(C::rocksdb_get_perf_metric_header(&self.column_options));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(serialized_value) = result? {
|
||||||
Ok(Some(C::Type::decode(&serialized_value[..])?))
|
Ok(Some(C::Type::decode(&serialized_value[..])?))
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
@ -2421,7 +2433,14 @@ where
|
|||||||
pub fn put_protobuf(&self, key: C::Index, value: &C::Type) -> Result<()> {
|
pub fn put_protobuf(&self, key: C::Index, value: &C::Type) -> Result<()> {
|
||||||
let mut buf = Vec::with_capacity(value.encoded_len());
|
let mut buf = Vec::with_capacity(value.encoded_len());
|
||||||
value.encode(&mut buf)?;
|
value.encode(&mut buf)?;
|
||||||
self.backend.put_cf(self.handle(), &C::key(key), &buf)
|
|
||||||
|
let is_perf_context_enabled = maybe_collect_perf_context();
|
||||||
|
let result = self.backend.put_cf(self.handle(), &C::key(key), &buf);
|
||||||
|
if is_perf_context_enabled {
|
||||||
|
report_write_perf_context(C::rocksdb_put_perf_metric_header(&self.column_options));
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user