summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-03-23 14:52:22 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-03-24 17:26:33 +0100
commitf9cf6812fdbd94de4e5076b9e524f8ff5505017e (patch)
treebde968aaf3a768d3581e6953d30f0fccf3f9682c
parent6a2a82648176e4b840bfed80e188c21b6bc63c4d (diff)
openpgp: Use larger default buffer size in DetachedVerifier.
- The DetachedVerifier uses the Transformer to construct a signed OpenPGP message on the fly from the given detached signature and data. The transformer synthesizes a literal data packet with partial body encoding, and the size of the chunks depends on the amount of data requested by the reader. - The transformer is wrapped in a buffered_reader::Generic to implement BufferedReader on top of io::Read. - Previously, we used the default preferred chunk size. This makes the transformer construct partial body chunks of size 8k, resulting in very poor performance. - This changes the preferred chunk size to 4MB. - The proper fix is to implement BufferedReader for Transformer to avoid unnecessary buffering. - Fixes #457.
-rw-r--r--openpgp/src/parse/stream.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/openpgp/src/parse/stream.rs b/openpgp/src/parse/stream.rs
index 3e695420..c81b5d32 100644
--- a/openpgp/src/parse/stream.rs
+++ b/openpgp/src/parse/stream.rs
@@ -994,9 +994,12 @@ impl DetachedVerifier {
let t = t.into();
Verifier::from_buffered_reader(
policy,
+ // XXX: impl BufferedReader for Transformer to reduce
+ // buffering.
Box::new(buffered_reader::Generic::with_cookie(
Transformer::new(signature_bio, reader)?,
- None, Default::default())),
+ Some(1 << 22), // 4MB.
+ Default::default())),
helper, t)
}
}