mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-11 11:49:50 +08:00
perf(gateway): scale request hot paths for 20k streams
Shard and singleflight hot-path caches, batch and prioritize candidate and usage lifecycle persistence, and extend database and pressure-test instrumentation for 20k concurrent streams.
This commit is contained in:
@@ -583,15 +583,25 @@ pub fn request_candidate_lifecycle_would_regress(
|
||||
| RequestCandidateStatus::Unused
|
||||
| RequestCandidateStatus::Pending
|
||||
| RequestCandidateStatus::Streaming
|
||||
) || existing == RequestCandidateStatus::Streaming
|
||||
&& incoming == RequestCandidateStatus::Pending
|
||||
) || existing == RequestCandidateStatus::Pending
|
||||
&& matches!(
|
||||
incoming,
|
||||
RequestCandidateStatus::Available | RequestCandidateStatus::Unused
|
||||
)
|
||||
|| existing == RequestCandidateStatus::Streaming
|
||||
&& matches!(
|
||||
incoming,
|
||||
RequestCandidateStatus::Available
|
||||
| RequestCandidateStatus::Unused
|
||||
| RequestCandidateStatus::Pending
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{
|
||||
derive_request_candidate_final_status, RequestCandidateFinalStatus, RequestCandidateStatus,
|
||||
StoredRequestCandidate,
|
||||
derive_request_candidate_final_status, request_candidate_lifecycle_would_regress,
|
||||
RequestCandidateFinalStatus, RequestCandidateStatus, StoredRequestCandidate,
|
||||
};
|
||||
|
||||
fn candidate(
|
||||
@@ -654,4 +664,44 @@ mod tests {
|
||||
RequestCandidateFinalStatus::Success
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn streaming_candidate_cannot_regress_to_an_earlier_planning_state() {
|
||||
for incoming in [
|
||||
RequestCandidateStatus::Available,
|
||||
RequestCandidateStatus::Unused,
|
||||
RequestCandidateStatus::Pending,
|
||||
] {
|
||||
assert!(request_candidate_lifecycle_would_regress(
|
||||
RequestCandidateStatus::Streaming,
|
||||
incoming,
|
||||
));
|
||||
}
|
||||
assert!(!request_candidate_lifecycle_would_regress(
|
||||
RequestCandidateStatus::Streaming,
|
||||
RequestCandidateStatus::Success,
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pending_candidate_cannot_regress_to_an_earlier_planning_state() {
|
||||
for incoming in [
|
||||
RequestCandidateStatus::Available,
|
||||
RequestCandidateStatus::Unused,
|
||||
] {
|
||||
assert!(request_candidate_lifecycle_would_regress(
|
||||
RequestCandidateStatus::Pending,
|
||||
incoming,
|
||||
));
|
||||
}
|
||||
for incoming in [
|
||||
RequestCandidateStatus::Streaming,
|
||||
RequestCandidateStatus::Success,
|
||||
] {
|
||||
assert!(!request_candidate_lifecycle_would_regress(
|
||||
RequestCandidateStatus::Pending,
|
||||
incoming,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user