-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Lock buffers in order of metadata #1722
Conversation
@repeatedly Could you review this change? |
lib/fluent/plugin/buffer.rb
Outdated
return 1 | ||
end | ||
# both of v1 and v2 are non-nil | ||
if v1.keys.sort != v2.keys.sort |
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.
v1.keys
and v2.keys
should be assigned to local variables because each keys
call creates new object.
metadata comparison is called heavily in buffers so reducing object allocation is better.
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.
I see. Will fix it.
BTW... with this patch, https://github.com/fluent/fluentd/blob/master/test/plugin/test_buffer.rb#L861 this assertion always fails. |
32c5f58
to
2369a4a
Compare
I've pushed commits to fix performance issue and existing tests. |
Thx! |
When 2 or more input plugin threads try to emit events into an output plugin (and its buffer plugin instance), it may occur dead-lock, because the order of chunks to be locked are random for now.
This change introduces to sort metadata before locking chunks, to lock chunks in same order in different threads.