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

Keep profile and history data in shared memory #66

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion collector.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,16 @@ probe_waits(const bool write_history, const bool write_profile)
if (write_history)
LWLockAcquire(pgws_history_lock, LW_EXCLUSIVE);

/* Iterate PGPROCs under shared lock */
/*
* Iterate PGPROCs under shared lock.
*
* TODO:
* ProcArrayLock is heavy enough and in current case we might perform the
* non-trivial deallocation routine for profile hash table under this lock.
* Therefore to reduce possible contention it's worth to segregate the logic
* of PGPROCs iteration under ProcArrayLock and storing results to profile
* and/or history under corresponding another lock.
*/
LWLockAcquire(ProcArrayLock, LW_SHARED);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we take ProcArrayLock anyway? What concurrent operations does it prevent?
I don't think that blocking ProcArrayAdd and ProcArrayRemove buys us anything. We are not iterating over the procArray, but over allProcs. And we don't need the lock to read PGPROC.pid and wait_event_info.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, you are right. In current case when we verify slot validity also via non-zero wait_event_info value we might omit acquisition of this lock. This is mostly inherited from previous implementation.

for (int i = 0; i < ProcGlobal->allProcCount; i++)
{
Expand Down