Skip to content

Commit

Permalink
Add hash method. no need to compare all varaible
Browse files Browse the repository at this point in the history
  • Loading branch information
ganmacs committed Aug 14, 2019
1 parent 6e486aa commit 079803e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/fluent/plugin/buffer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,15 @@ def <=>(o)
cmp_variables(variables, variables2)
end
end

# This is an optimization code. Current Struct's implementation is comparing all data.
# https://github.com/ruby/ruby/blob/0623e2b7cc621b1733a760b72af246b06c30cf96/struct.c#L1200-L1203
# Actually this overhead is very small but this class is generated *per chunk* (and used in hash object).
# This means that this class is one of the most called object in Fluentd.
# See https://github.com/fluent/fluentd/pull/2560
def hash
timekey.object_id
end
end

# for tests
Expand Down

0 comments on commit 079803e

Please sign in to comment.