Skip to content
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

Merged

Conversation

yaauie
Copy link
Contributor

@yaauie yaauie commented Mar 20, 2024

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.

@yaauie yaauie force-pushed the reuse-packforward-payload-unpacker branch from f78fb3a to 4e46d3e Compare March 20, 2024 21:17
Copy link
Contributor

@mashhurs mashhurs left a 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]>
Copy link

@andsel andsel left a 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)
Copy link

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?

Copy link
Contributor Author

@yaauie yaauie Jun 25, 2024

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.

@yaauie yaauie merged commit 96df688 into logstash-plugins:main Jun 25, 2024
2 checks passed
@yaauie yaauie deleted the reuse-packforward-payload-unpacker branch June 25, 2024 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants