-
Notifications
You must be signed in to change notification settings - Fork 22
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
perf: reuse inner packforward payload unpacker #32
perf: reuse inner packforward payload unpacker #32
Conversation
f78fb3a
to
4e46d3e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Co-authored-by: Mashhur <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let a comment on a possible threading issue
@@ -116,7 +117,7 @@ def decode_event(data, &block) | |||
raise(LogStash::Error, "PackedForward with compression is not supported") | |||
end | |||
|
|||
entries_decoder = @factory.unpacker | |||
entries_decoder = (@packforward_decoder ||= @factory.unpacker).tap(&:reset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand decode
, when used by a input like TCP (which is multithreaded), is used by multiple threads, so I have feeling that @packforward_decoder.reset
could be called and used by multiple threads.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TCP clones the codec (as do other inputs), and gives a fresh codec to each connection, so this should never be shared.
A codec instance needs at-most-one packforward payload unpacker, as it is never decoding input concurrently, so long as the unpacker is reset before use.