-
Notifications
You must be signed in to change notification settings - Fork 4
Reject transport-changing extensions #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mjc
merged 3 commits into
nntpp-33-xhdr-framing
from
nntpp-34-transport-extension-rejection
Sep 11, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| //! Mixed hybrid-cache workload for metadata and retained-payload updates. | ||
| //! | ||
| //! Run with: `cargo bench --bench cache_metadata_payload` | ||
|
|
||
| use divan::Bencher; | ||
| use nntp_proxy::cache::{HybridCacheConfig, UnifiedCache}; | ||
| use nntp_proxy::protocol::StatusCode; | ||
| use nntp_proxy::types::{BackendId, MessageId}; | ||
| use std::sync::atomic::{AtomicU64, Ordering}; | ||
| use std::time::Duration; | ||
| use tempfile::{TempDir, tempdir}; | ||
|
|
||
| const ARTICLE_BODY: &str = "x"; | ||
|
|
||
| fn main() { | ||
| divan::main(); | ||
| } | ||
|
|
||
| fn benchmark_cache() -> (tokio::runtime::Runtime, TempDir, UnifiedCache) { | ||
| let runtime = tokio::runtime::Runtime::new().expect("benchmark runtime"); | ||
| let directory = tempdir().expect("benchmark cache directory"); | ||
| let config = HybridCacheConfig { | ||
| memory_capacity: 4 * 1024 * 1024, | ||
| disk_capacity: 64 * 1024 * 1024, | ||
| disk_path: directory.path().to_path_buf(), | ||
| ttl: Duration::from_secs(300), | ||
| compression: nntp_proxy::config::CompressionCodec::None, | ||
| shards: 16, | ||
| }; | ||
| let cache = runtime | ||
| .block_on(UnifiedCache::hybrid(config)) | ||
| .expect("hybrid cache"); | ||
| (runtime, directory, cache) | ||
| } | ||
|
|
||
| fn message_id(sequence: u64) -> MessageId<'static> { | ||
| MessageId::new(format!("<bench-{sequence}@example.com>")).expect("benchmark message ID") | ||
| } | ||
|
|
||
| fn article_response(sequence: u64) -> Vec<u8> { | ||
| format!( | ||
| "220 42 <bench-{sequence}@example.com>\r\nSubject: Benchmark\r\n\r\n{ARTICLE_BODY}\r\n.\r\n" | ||
| ) | ||
| .into_bytes() | ||
| } | ||
|
|
||
| #[divan::bench(sample_count = 20, sample_size = 1)] | ||
| fn metadata_only_updates(bencher: Bencher) { | ||
| let (runtime, _directory, cache) = benchmark_cache(); | ||
| let sequence = AtomicU64::new(0); | ||
|
|
||
| bencher | ||
| .with_inputs(|| message_id(sequence.fetch_add(1, Ordering::Relaxed))) | ||
| .bench_values(|id| { | ||
| runtime.block_on(cache.record_backend_has_status( | ||
| id, | ||
| StatusCode::new(223), | ||
| BackendId::from_index(0), | ||
| 0.into(), | ||
| )); | ||
| }); | ||
|
|
||
| runtime | ||
| .block_on(cache.close()) | ||
| .expect("close benchmark cache"); | ||
| } | ||
|
|
||
| #[divan::bench(sample_count = 20, sample_size = 1)] | ||
| fn retained_payload_updates(bencher: Bencher) { | ||
| let (runtime, _directory, cache) = benchmark_cache(); | ||
| let sequence = AtomicU64::new(0); | ||
|
|
||
| bencher | ||
| .with_inputs(|| { | ||
| let sequence = sequence.fetch_add(1, Ordering::Relaxed); | ||
| (message_id(sequence), article_response(sequence)) | ||
| }) | ||
| .bench_values(|(id, response)| { | ||
| runtime.block_on(cache.upsert_ingest(id, response, BackendId::from_index(0), 0.into())); | ||
| }); | ||
|
|
||
| runtime | ||
| .block_on(cache.close()) | ||
| .expect("close benchmark cache"); | ||
| } | ||
|
|
||
| #[divan::bench(sample_count = 20, sample_size = 1)] | ||
| fn mixed_metadata_and_payload_updates(bencher: Bencher) { | ||
| let (runtime, _directory, cache) = benchmark_cache(); | ||
| let sequence = AtomicU64::new(0); | ||
|
|
||
| bencher | ||
| .with_inputs(|| { | ||
| let sequence = sequence.fetch_add(2, Ordering::Relaxed); | ||
| ( | ||
| message_id(sequence), | ||
| message_id(sequence + 1), | ||
| article_response(sequence + 1), | ||
| ) | ||
| }) | ||
| .bench_values(|(metadata_id, payload_id, response)| { | ||
| runtime.block_on(async { | ||
| cache | ||
| .record_backend_has_status( | ||
| metadata_id, | ||
| StatusCode::new(223), | ||
| BackendId::from_index(0), | ||
| 0.into(), | ||
| ) | ||
| .await; | ||
| cache | ||
| .upsert_ingest(payload_id, response, BackendId::from_index(0), 0.into()) | ||
| .await; | ||
| }); | ||
| }); | ||
|
|
||
| runtime | ||
| .block_on(cache.close()) | ||
| .expect("close benchmark cache"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.