Github user revans2 commented on a diff in the pull request:
https://github.com/apache/storm/pull/2203#discussion_r160544887
--- Diff: storm-core/src/clj/org/apache/storm/daemon/executor.clj ---
@@ -446,7 +451,7 @@
(.ack spout msg-id)
(task/apply-hooks (:user-context task-data) .spoutAck (SpoutAckInfo.
msg-id task-id time-delta))
(when time-delta
- (stats/spout-acked-tuple! (:stats executor-data) (:stream
tuple-info) time-delta))))
+ (stats/spout-acked-tuple! (:stats executor-data)
(StormMetricRegistry/counter "acked" (:worker-context executor-data)
(:component-id executor-data) (pr-str (:executor-id executor-data)) (:stream
tuple-info)) (:stream tuple-info) time-delta))))
--- End diff --
I think we can turn it into just a map lookup, although I don't know how
much work that will be.
We should know the stream names ahead of time, from the StormTopology. As
such we can create all of the metrics ahead of time for each bolt/spout
instance, and cache them in a map keyed by the stream id. Then when a tuple is
Emitted/Acked/etc. we look up the Counter based off of the stream id and use
it. No object allocation and no string concatenation involved.
If we don't want to bother with parsing the StormTopology and prepopulating
it, we could do lazy initialization like we are doing now.
---