[ClickHouse-57381]Implement MemoryCredits profile event to track memory usage over time.#66478
[ClickHouse-57381]Implement MemoryCredits profile event to track memory usage over time.#66478Zawa-ll wants to merge 32 commits intoClickHouse:masterfrom
Conversation
src/Common/ProfileEvents.h
Outdated
There was a problem hiding this comment.
No, it should be at the place of the usage.
src/Common/ProfileEvents.cpp
Outdated
There was a problem hiding this comment.
Not clear enough what credits are.
src/Common/MemoryTracker.h
Outdated
There was a problem hiding this comment.
Having these two members looks excessive.
There was a problem hiding this comment.
Sure, these two variables were moved to the function MemoryTracker::updateMemoryCredits()
void MemoryTracker::updateMemoryCredits()
{
+ static Stopwatch stopwatch;
+ static size_t previous_value = 0;
size_t current_value = amount;
if (current_value > previous_value && current_value - previous_value > threshold)
{
size_t delta = (current_value - previous_value) * stopwatch.elapsedMicroseconds();
ProfileEvents::increment(ProfileEvents::MemoryCredits, delta);
previous_value = current_value;
stopwatch.restart();
}
}
If you have a better approach, please let me know! Thank you!
src/Common/MemoryTracker.cpp
Outdated
src/Common/MemoryTracker.cpp
Outdated
|
@alexey-milovidov Thank you for your response! Changes were made! Also I notice that the workflow required approval... Can you approve this for me? Thank you! |
|
This is an automated comment for commit d76c6cf with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
40a5339 to
0c3f28e
Compare
src/Common/MemoryTracker.h
Outdated
There was a problem hiding this comment.
Why mix 2 completely different variables? The original threshold was to throw logical errors in debug mode, but now you are using it to update memory credits too, so we can't change one without changing the other.
There was a problem hiding this comment.
Changes were made! I misunderstand the relationship between the two variables.
61bf761 to
c3e72de
Compare
src/Common/ProfileEvents.cpp
Outdated
There was a problem hiding this comment.
Arent microseconds*bytes can be really big number (plus, with high randomity in it)?
May be, it make sense to have it as microseconds*MB or round lower bits, but keep bytes then.
|
@alexey-milovidov Hi I just notice that the build failed for some reason... I don't think they are quite relevant to my code changes, can you provide me with some clue on how this is supposed to be fixed? |
|
Not only builds have failed, but basically everything in this pull request. Read the details of the corresponding checks... |
Logic for handling data race has been added! |
|
@alexey-milovidov Can you please take a look at this PR again? I double check the failing checks and still await for some instructions on how this failing check caused by ec2_admin should be handled... |
…r stable test results.
Remove logic for global threshold variables Remove logic for global threshold variable and create a local_variables
d31d6c3 to
567943b
Compare
|
Updates: Based on @ Avogar, some falky tests still needs to be fixed,I will continue working on this one once they are merged, please do not close this PR, thank you!!! |
|
Dear @alexey-milovidov, this PR hasn't been updated for a while. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Implement
MemoryCreditsprofile event to track memory usage over time.Documentation entry for user-facing changes
Documentation Information:
MemoryCredits: A profile event that counts the amount of microseconds*bytes (or megabytes) consumed by a query.CI Settings (Only check the boxes if you know what you are doing):
This addresses issue #57381.