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

Wall-time/all tasks profiler #55889

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Wall-time/all tasks profiler #55889

wants to merge 1 commit into from

Conversation

d-netto
Copy link
Member

@d-netto d-netto commented Sep 26, 2024

One limitation of sampling CPU/thread profiles, as is currently done in Julia, is that they primarily capture samples from CPU-intensive tasks.

If many tasks are performing IO or contending for concurrency primitives like semaphores, these tasks won’t appear in the profile, as they aren't scheduled on OS threads sampled by the profiler.

A wall-time profiler, like the one implemented in this PR, samples tasks regardless of OS thread scheduling. This enables profiling of IO-heavy tasks and detecting areas of heavy contention in the system.

Unix-only for now...

Co-developed with @nickrobinson251.

@d-netto
Copy link
Member Author

d-netto commented Sep 26, 2024

An additional note: this kind of wall-time/all tasks profiler is also implemented in Go (and denoted as goroutine profiler there), so there is some precedent for this in other languages as well: https://github.com/felixge/fgprof.

@d-netto
Copy link
Member Author

d-netto commented Sep 26, 2024

@nickrobinson251 I can't assign you as reviewer... Feel free to assign yourself or post review comments otherwise.

@d-netto d-netto force-pushed the dcn-all-task-profiler branch 2 times, most recently from 6b80fe3 to f5c8f5f Compare September 26, 2024 14:13
@IanButterworth
Copy link
Sponsor Member

I think this is related to #55103. Could the metrics here be useful in that too?

@d-netto d-netto force-pushed the dcn-all-task-profiler branch 2 times, most recently from 1e9f41f to 6cd27d7 Compare September 26, 2024 16:02
@nsajko nsajko added the feature Indicates new feature / enhancement requests label Sep 26, 2024
@d-netto d-netto force-pushed the dcn-all-task-profiler branch 3 times, most recently from f6ea007 to 1029a84 Compare September 27, 2024 11:38
@d-netto d-netto force-pushed the dcn-all-task-profiler branch 3 times, most recently from 0d4ca9c to e493403 Compare September 30, 2024 11:42
@d-netto
Copy link
Member Author

d-netto commented Sep 30, 2024

I think this is related to #55103. Could the metrics here be useful in that too?

For diagnosing excessive scheduling time? I can't immediately see how this PR would be useful for that.

@d-netto
Copy link
Member Author

d-netto commented Sep 30, 2024

For diagnosing excessive scheduling time

#55103 seems like a much more direct approach for doing so, at least.

@d-netto d-netto force-pushed the dcn-all-task-profiler branch 2 times, most recently from 90bca24 to 14766d3 Compare September 30, 2024 14:57
@NHDaly NHDaly added the needs tests Unit tests are required for this change label Oct 1, 2024
Copy link
Member

Choose a reason for hiding this comment

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

I just added the needs tests label. Can you please add julia tests (integration tests) for this feature?

We should be testing at least these properties, maybe more:

  • That it works at all
  • That you do see sleeping Tasks

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good. Yes, adding tests is in my TODO list for this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

That you do see sleeping Tasks

Now that I'm thinking about it: can we test this reliably?

The example I was thinking about was something like:

Profile.@profile_tasks sleep(1)

But the point here is: I think it may be possible for the profiler thread to get delayed arbitrarily and by the time it samples the given task, it's no longer sleeping.

src/task.c Outdated Show resolved Hide resolved
@d-netto d-netto force-pushed the dcn-all-task-profiler branch 2 times, most recently from 5ddd5ba to c9d1995 Compare October 3, 2024 12:50
@d-netto d-netto force-pushed the dcn-all-task-profiler branch 12 times, most recently from bd13e1b to 2d7ebeb Compare October 7, 2024 13:32
@d-netto d-netto force-pushed the dcn-all-task-profiler branch 4 times, most recently from 30ce700 to 3ef9df7 Compare October 8, 2024 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Indicates new feature / enhancement requests needs tests Unit tests are required for this change profiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants