Skip to content
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

Add last_fork_start_time to INFO STATS #978

Open
wants to merge 4 commits into
base: unstable
Choose a base branch
from

Conversation

enjoy-binbin
Copy link
Member

@enjoy-binbin enjoy-binbin commented Sep 2, 2024

Sometimes we want to know the last fork start time, this can help
user to analyze the stability since right now fork is still
a costly operation and user can monitor forks by drawing graphs
based on these fork fields.

fork is still a very resource-intensive process, so it makes sense
to record the time each fork is triggered. Adding a last_fork_start_time
field in INFO STATS, to record the last fork start time in us.

Sometimes we want to know the last fork time, this can help
user to analyze the stability since right now fork is still
a costly operation and user can monitor forks by drawing graphs
based on these fork fields.

Signed-off-by: Binbin <[email protected]>
@enjoy-binbin
Copy link
Member Author

Currently the time is, a successful fork, when it start, is recorded. We can also record the last failed fork time if needed.

Copy link

codecov bot commented Sep 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.65%. Comparing base (789a73b) to head (d914f67).
Report is 1 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable     #978      +/-   ##
============================================
- Coverage     70.66%   70.65%   -0.02%     
============================================
  Files           114      114              
  Lines         63150    63152       +2     
============================================
- Hits          44624    44619       -5     
- Misses        18526    18533       +7     
Files with missing lines Coverage Δ
src/server.c 87.71% <100.00%> (+<0.01%) ⬆️
src/server.h 100.00% <ø> (ø)

... and 11 files with indirect coverage changes

src/server.c Outdated
@@ -6304,6 +6306,7 @@ int serverFork(int purpose) {
server.stat_fork_time = ustime() - start;
server.stat_fork_rate =
(double)zmalloc_used_memory() * 1000000 / server.stat_fork_time / (1024 * 1024 * 1024); /* GB per second. */
server.stat_last_fork_time = start;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand why server.stat_last_fork_time is needed if we already have server.stat_fork_time. (I'm assuming what you really want to know is how long fork took, which can be quite long with large datasets.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming what you really want to know is how long fork took, which can be quite long with large datasets

we already has this info: latest_fork_usec: Duration of the latest fork operation in microseconds

here this latest_fork_time is the time when the last fork was triggered, something like that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify how this info is useful ? Would tracking the bgsave start time be more informative? Also, renaming it to last_fork_start_time or last_fork_start_timestamp might avoid confusion with server.stat_fork_time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have other ways that can trigger fork, like aofrw, tracking the bgsave start time maybe not enought.

fork is still a very resource-intensive process, so it makes sense for me to record the time each fork is triggered.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood.
I'd suggest renaming the variable as mentioned above; other than that, the code looks fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good naming idea, sorry for the confusion. (bad english, unable to think of a good name right away...)

@enjoy-binbin enjoy-binbin changed the title Add latest_fork_time to INFO STATS Add last_fork_start_time to INFO STATS Oct 30, 2024
Copy link
Member

@xbasel xbasel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these config files and text file committed by accident?

Signed-off-by: Binbin <[email protected]>
@enjoy-binbin
Copy link
Member Author

Were these config files and text file committed by accident?

yes.. sorry for that, i did not check after push

Copy link
Member

@xbasel xbasel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need also to update https://valkey.io/commands/info/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants