-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Isolate MAL CounterWindow cache by metric name. #11526
Isolate MAL CounterWindow cache by metric name. #11526
Conversation
Test not ready, I want confirm code first. |
Please make sure the codes work first. Otherwise, we don't know it is missing change or on purpose. |
Sorry, I will complete test first. |
Unit Test is ready. |
return Optional.ofNullable(CACHE.get()); | ||
} | ||
|
||
private final static ThreadLocal<ExpressionRunningContext> CACHE = new ThreadLocal<>(); |
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.
So, you are forwarding the metric cache into this runtime CACHE for MAL runtime? Is this your basic principle?
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.
Yes, ThreadLocal has sampleFamilies before, I newly add metric name.
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.
The metrics name is from the YAML, which is constant instead of a variable value. It's better to add it to the "ExpressionDelegate" as a field. Then inject the metric name into the samplefamilily in "propertyMissing"
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.
@hanahmily Ok, thanks. I will try this way.
Let's wait for others to review this. I am not familiar with this part of the codes. |
Ok. |
One question, if two expressions share the same metric source(counter), but use different rate, how does the cache keep the longer time windows for the further calculation? |
Two expression will create two cache in window, one for shorter and one for longer. |
Seems use metric name as id name will cause memory waste, expressions can not share cache in some cases? |
Yes, but it seems easier at the implementation level. Do you have idea to optimize it by using the longer range? |
I have no idea about optimize yet. |
OK, let's keep the status for now. I think this not a big issue of a little more extra memory cost. |
How about use expression prefix as Id name and maintain a field in window to record lower bound calculate by long rate, For example:
the 3 metrics above will create window by 2 ids, and the first one window length is 1h, the second one window length is 1M:
|
Let's not bring this complexity into the codes this time. Let's keep one expression per cache if it is a counter. |
Ok, I will follow this. |
… in "propertyMissing".
I have add a field named metricName in ExpressionDelegate and inject it to samplefamily runningcontext in "propertyMissing" |
@kezhenxu94 @wankai123 Could any of you run another check? |
Thanks. |
Fix MAL CounterWindow Isolation.
CHANGES
log.