mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-12-01 07:04:09 +00:00
feat(sketch): report shared samples and directory probes
Carry additive sampling counters through region RPC and validate unique payload accounting with overlapping proposal and validation samples. Document directory-only probes separately from the payload file limit and allow directory-proven empty buckets in a census. Update the generated Cargo lockfile for the proto revision; the resolver also reselects existing dependency edges without changing package versions. Signed-off-by: WenyXu <wenymedia@gmail.com>
This commit is contained in:
Generated
+11
-11
@@ -1657,7 +1657,7 @@ dependencies = [
|
||||
"maybe-owned",
|
||||
"rustix 1.0.7",
|
||||
"rustix-linux-procfs",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
"winx",
|
||||
]
|
||||
|
||||
@@ -6160,7 +6160,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "greptime-proto"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/GreptimeTeam/greptime-proto.git?rev=9aa28f23abeea4f2b37ce14a74a583eb169e2fb0#9aa28f23abeea4f2b37ce14a74a583eb169e2fb0"
|
||||
source = "git+https://github.com/GreptimeTeam/greptime-proto.git?rev=258d97884a4fd046bdb638700a5e3b1da53c12b1#258d97884a4fd046bdb638700a5e3b1da53c12b1"
|
||||
dependencies = [
|
||||
"prost 0.14.1",
|
||||
"prost-types 0.14.1",
|
||||
@@ -6772,7 +6772,7 @@ dependencies = [
|
||||
"libc",
|
||||
"percent-encoding",
|
||||
"pin-project-lite",
|
||||
"socket2 0.6.4",
|
||||
"socket2 0.5.10",
|
||||
"tokio",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
@@ -9348,7 +9348,7 @@ version = "0.50.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
|
||||
dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -11624,7 +11624,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac6c3320f9abac597dcbc668774ef006702672474aad53c6d596b62e487b40b1"
|
||||
dependencies = [
|
||||
"heck 0.5.0",
|
||||
"itertools 0.11.0",
|
||||
"itertools 0.10.5",
|
||||
"log",
|
||||
"multimap",
|
||||
"once_cell",
|
||||
@@ -11672,7 +11672,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a56d757972c98b346a9b766e3f02746cde6dd1cd1d1d563472929fdd74bec4d"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"itertools 0.11.0",
|
||||
"itertools 0.10.5",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.117",
|
||||
@@ -11685,7 +11685,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9120690fafc389a67ba3803df527d0ec9cbbc9cc45e4cc20b332996dfb672425"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"itertools 0.11.0",
|
||||
"itertools 0.10.5",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.117",
|
||||
@@ -13241,7 +13241,7 @@ dependencies = [
|
||||
"security-framework 3.7.0",
|
||||
"security-framework-sys",
|
||||
"webpki-root-certs",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -14163,7 +14163,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -14734,7 +14734,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"psm",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -15359,7 +15359,7 @@ dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
"once_cell",
|
||||
"rustix 1.0.7",
|
||||
"windows-sys 0.61.2",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
+1
-1
@@ -164,7 +164,7 @@ fs2 = "0.4"
|
||||
fst = "0.4.7"
|
||||
futures = "0.3"
|
||||
futures-util = "0.3"
|
||||
greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "9aa28f23abeea4f2b37ce14a74a583eb169e2fb0" }
|
||||
greptime-proto = { git = "https://github.com/GreptimeTeam/greptime-proto.git", rev = "258d97884a4fd046bdb638700a5e3b1da53c12b1" }
|
||||
hdfs-native = "0.14.6"
|
||||
hex = "0.4"
|
||||
hostname = "0.4.0"
|
||||
|
||||
@@ -810,6 +810,8 @@ mod tests {
|
||||
sampled_files: 2048,
|
||||
proposal_files: 1024,
|
||||
validation_files: 1024,
|
||||
shared_files: 0,
|
||||
directory_files: 0,
|
||||
rounds: 5,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -455,6 +455,8 @@ mod test {
|
||||
sampled_files: 0,
|
||||
proposal_files: 0,
|
||||
validation_files: 0,
|
||||
shared_files: 0,
|
||||
directory_files: 0,
|
||||
rounds: 0,
|
||||
gaps: vec![],
|
||||
})
|
||||
|
||||
@@ -111,7 +111,8 @@ impl SketchRequest {
|
||||
}
|
||||
|
||||
/// Proposes and validates split points within one pinned SST snapshot.
|
||||
/// File limits count unique files across the proposal and validation samples together.
|
||||
/// File limits count unique algorithm-payload files across both samples.
|
||||
/// Additional directory probes use separate byte budgets and concurrency limits.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct SketchSplitRequest {
|
||||
pub time_range: SketchTimeRange,
|
||||
@@ -122,7 +123,7 @@ pub struct SketchSplitRequest {
|
||||
pub initial_files: u32,
|
||||
/// Minimum total files before a sampled result may be accepted.
|
||||
pub min_files: u32,
|
||||
/// Maximum total unique files read across all sampling rounds.
|
||||
/// Maximum unique algorithm-payload files across rounds, excluding directory-only probes.
|
||||
pub max_files: u32,
|
||||
pub seed: u64,
|
||||
/// Maximum allowed CDF disagreement; this is not a statistical confidence bound.
|
||||
@@ -183,7 +184,8 @@ pub struct SketchSplitPoint {
|
||||
pub enum SketchSplitStatus {
|
||||
/// Both samples satisfy the requested stability and partition-mass controls.
|
||||
Validated,
|
||||
/// Every candidate file was read and the requested partition-mass controls hold.
|
||||
/// Every candidate was accounted for and the partition-mass controls hold.
|
||||
/// Complete directories may prove empty buckets without reading algorithm payloads.
|
||||
Census,
|
||||
/// Sampling exhausted its file budget without satisfying the controls.
|
||||
Unstable,
|
||||
@@ -202,12 +204,16 @@ pub struct SketchSplitResponse {
|
||||
pub points: Vec<SketchSplitPoint>,
|
||||
/// Number of unique files eligible before sampling.
|
||||
pub candidate_files: u64,
|
||||
/// Total unique files read, equal to proposal_files plus validation_files.
|
||||
/// Unique payload files: proposal_files + validation_files - shared_files.
|
||||
pub sampled_files: u64,
|
||||
/// Files used to propose boundaries; includes all files for a census.
|
||||
/// Files used to propose boundaries; includes all nonempty payloads for a census.
|
||||
pub proposal_files: u64,
|
||||
/// Disjoint files used to evaluate boundaries; zero for a census.
|
||||
/// Files used to evaluate boundaries; may overlap proposal files; zero for a census.
|
||||
pub validation_files: u64,
|
||||
/// Files contributing to both samples, read once.
|
||||
pub shared_files: u64,
|
||||
/// Unique directory probes, including cache hits; may exceed the payload file limit.
|
||||
pub directory_files: u64,
|
||||
pub rounds: u32,
|
||||
pub gaps: Vec<SketchGap>,
|
||||
}
|
||||
|
||||
@@ -474,6 +474,8 @@ impl TryFrom<pb::SketchSplitResponse> for SketchSplitResponse {
|
||||
sampled_files: response.sampled_files,
|
||||
proposal_files: response.proposal_files,
|
||||
validation_files: response.validation_files,
|
||||
shared_files: response.shared_files,
|
||||
directory_files: response.directory_files,
|
||||
rounds: response.rounds,
|
||||
gaps: response
|
||||
.gaps
|
||||
@@ -513,6 +515,8 @@ impl TryFrom<SketchSplitResponse> for pb::SketchSplitResponse {
|
||||
sampled_files: response.sampled_files,
|
||||
proposal_files: response.proposal_files,
|
||||
validation_files: response.validation_files,
|
||||
shared_files: response.shared_files,
|
||||
directory_files: response.directory_files,
|
||||
rounds: response.rounds,
|
||||
gaps: response.gaps.into_iter().map(Into::into).collect(),
|
||||
})
|
||||
@@ -526,8 +530,11 @@ fn validate_split_response(response: &SketchSplitResponse) -> Result<(), BoxedEr
|
||||
);
|
||||
if response
|
||||
.proposal_files
|
||||
.checked_add(response.validation_files)
|
||||
.checked_sub(response.shared_files)
|
||||
.and_then(|count| count.checked_add(response.validation_files))
|
||||
!= Some(response.sampled_files)
|
||||
|| response.shared_files > response.validation_files
|
||||
|| response.directory_files > response.candidate_files
|
||||
|| response.sampled_files > response.candidate_files
|
||||
|| (response.sampled_files > 0 && response.rounds == 0)
|
||||
|| response.points.len() > 63
|
||||
@@ -537,9 +544,7 @@ fn validate_split_response(response: &SketchSplitResponse) -> Result<(), BoxedEr
|
||||
|| response.proposal_files == 0))
|
||||
|| (!actionable && !response.points.is_empty())
|
||||
|| (response.status == SketchSplitStatus::Validated && response.validation_files == 0)
|
||||
|| (response.status == SketchSplitStatus::Census
|
||||
&& (response.validation_files != 0
|
||||
|| response.sampled_files != response.candidate_files))
|
||||
|| (response.status == SketchSplitStatus::Census && response.validation_files != 0)
|
||||
{
|
||||
return Err(invalid("inconsistent sketch split outcome or file counts"));
|
||||
}
|
||||
@@ -637,6 +642,8 @@ mod tests {
|
||||
sampled_files: 512,
|
||||
proposal_files: 256,
|
||||
validation_files: 256,
|
||||
shared_files: 0,
|
||||
directory_files: 512,
|
||||
rounds: 3,
|
||||
gaps: vec![],
|
||||
}
|
||||
@@ -667,6 +674,39 @@ mod tests {
|
||||
SketchSplitResponse::try_from(wire.clone()).unwrap(),
|
||||
response
|
||||
);
|
||||
// Independent samples can reuse payloads while probing every candidate directory.
|
||||
let mut shared = response.clone();
|
||||
shared.proposal_files = 320;
|
||||
shared.validation_files = 256;
|
||||
shared.shared_files = 64;
|
||||
shared.directory_files = shared.candidate_files;
|
||||
assert_eq!(
|
||||
SketchSplitResponse::try_from(
|
||||
pb::SketchSplitResponse::try_from(shared.clone()).unwrap()
|
||||
)
|
||||
.unwrap(),
|
||||
shared
|
||||
);
|
||||
// Additive counters default to zero when decoding earlier responses.
|
||||
let mut legacy = wire.clone();
|
||||
legacy.directory_files = 0;
|
||||
assert!(SketchSplitResponse::try_from(legacy).is_ok());
|
||||
for (proposal, validation, overlap, sampled) in [
|
||||
(256, 256, 257, 255),
|
||||
(320, 32, 64, 288),
|
||||
(256, 256, 64, 512),
|
||||
(u64::MAX, 1, 0, u64::MAX),
|
||||
] {
|
||||
let mut invalid = wire.clone();
|
||||
invalid.proposal_files = proposal;
|
||||
invalid.validation_files = validation;
|
||||
invalid.shared_files = overlap;
|
||||
invalid.sampled_files = sampled;
|
||||
assert!(SketchSplitResponse::try_from(invalid).is_err());
|
||||
}
|
||||
let mut invalid = wire.clone();
|
||||
invalid.directory_files = invalid.candidate_files + 1;
|
||||
assert!(SketchSplitResponse::try_from(invalid).is_err());
|
||||
for status in [0, 100] {
|
||||
let mut invalid = wire.clone();
|
||||
invalid.status = status;
|
||||
@@ -710,6 +750,16 @@ mod tests {
|
||||
.unwrap(),
|
||||
census
|
||||
);
|
||||
// Complete directories can establish empty buckets without payload reads.
|
||||
census.candidate_files += 10;
|
||||
census.directory_files = census.candidate_files;
|
||||
assert_eq!(
|
||||
SketchSplitResponse::try_from(
|
||||
pb::SketchSplitResponse::try_from(census.clone()).unwrap()
|
||||
)
|
||||
.unwrap(),
|
||||
census
|
||||
);
|
||||
let mut missing = response;
|
||||
missing.status = SketchSplitStatus::MissingCoverage;
|
||||
missing.points.clear();
|
||||
|
||||
Reference in New Issue
Block a user