Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Track on CPU events too#74

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

ants
Copy link
Contributor

To not count dead backends as still running on the CPU we need to detect that the backend is dead. Starting from PG17 proc->pid is reset in ProcKill, before this we can check if the process latch is disowned. Not nice to be poking around in latch internals like this, but all alternatives seem to involve scanning bestatus array and correlating pids.

Verified that the latch disown mechanism works on at least PostgreSQL 12-16.

Also makes sense to exclude ourselves as we will always be on CPU while looking at wait events.

Resolves#10

NikolayS reacted with thumbs up emoji
To not count dead backends as still running on the CPU we need todetect that the backend is dead. Starting from PG17 proc->pid is resetin ProcKill, before this we can check if the process latch is disowned.Not nice to be poking around in latch internals like this, but allalternatives seem to involve scanning bestatus array and correlatingpids.Also makes sense to exclude ourselves as we will always be on CPU whilelooking at wait events.
@ants
Copy link
ContributorAuthor

Should I add a GUC to turn this functionality on and off?

@shinderukshinderuk self-requested a reviewJune 13, 2024 07:32
@shinderuk
Copy link
Contributor

Thanks for working on this! I did some tests with pgbench and the results look good. Yes, I think we need a GUC to turn this on. Also the pg_wait_sampling_current view needs to be patched similarly.

Defaults to false meaning previous behavior is retained. Updatepg_wait_sampling_current view to respect this flag.
@ants
Copy link
ContributorAuthor

Added a sample_cpu GUC and updated the pg_wait_sampling_current view. GUC defaults to false for backwards compatibility. What is the preference on this? I think most people would want to see the events, so maybe it should default to true?

Copy link
Contributor

@shinderukshinderuk left a comment

Choose a reason for hiding this comment

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

Thank you. Looks good, except for a couple minor things.

Why not turn sample_cpu = on by default? Mainly for backward compatibility. I'm afraid that blank event_type in the profile would puzzle unprepared users or break UI. Also, turning it on could overflow the history buffer with new rows requiring adjustment of history_size. Anyway, I'm not sure which default is more useful for a regular user. Does it make sense?

@shinderukshinderuk merged commit12c0f7d intopostgrespro:masterJun 17, 2024
1 check passed
@egor-rogov
Copy link

Thank you guys!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@shinderukshinderukshinderuk requested changes

Assignees

@antsants

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

No information about "no wait" state
3 participants
@ants@shinderuk@egor-rogov

[8]ページ先頭

©2009-2025 Movatter.jp