Perf improvements#81
Merged
Merged
Conversation
Previously, pq would create the fully-qualified msgtype (i.e., by preprending a period) inside the decode loop. This commit moves that operation outside the loop. API change: PqDecoder::new expects its msgtype to be fully qualified.
This commit creates a CustomFormatter once, outside the decoding loop, and passes a reference to that formatter to PqDecoder::decode_message. API change: the PqDecoder::decode_message method accepts a CustomerFormatter as its third argument rather than a bool.
This is in preparation for making pq multi-threaded; the trait `Read` is not `Send` and so with the previous declaration (read: &'a mut Read) ByteConsumer was _not_ Send and could not be moved into a closure, i.e., with thread::spawn. This commit modifies the API of ByteConsumer by making it take ownership of a value of type T where T implements the Read trait.
This commit adds concurrency to the decoding part of CommandRunner::decode_or_convert. A pair of threads -- a producer and a consumer -- are spawned; the producer decodes Protobuf values and sends the decoded Value over a channel to the consumer who encodes the values to JSON and outputs them to stdout.
Owner
|
Something about adding threading makes me vaguely uneasy... But the numbers don't lie. When I get some time I'll look it over and merge it. |
Owner
|
Tests pass so lgtm. |
Merged
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR improves the performance of pq.
In the tests I've performed the performance increase varies between 50% and 100%.