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

Measure GIL contention in benchmarks #937

Merged
merged 4 commits into from
Oct 13, 2023

Conversation

pentschev
Copy link
Member

Add argument to measure and report GIL contention in benchmarks. This may provide some useful insight when optimizing asyncio-related changes.

Sample results observed are below.

Small messages (1 B)
$ python -m ucp.benchmarks.send_recv --backend ucp-core --n-bytes 1 --n-iter 100_000 --no-detailed-report --report-gil-contention
...
GIL contention            | 0.688429594039917

$ python -m ucp.benchmarks.send_recv --backend ucp-async --n-bytes 1 --n-iter 100_000 --no-detailed-report --report-gil-contention
...
GIL contention            | 0.4772491455078125

$ UCXPY_NON_BLOCKING_MODE=1 python -m ucp.benchmarks.send_recv --backend ucp-async --n-bytes 1 --n-iter 100_000 --no-detailed-report --report-gil-contention
...
GIL contention            | 0.8763511180877686
Medium messages (1 MiB)
$ python -m ucp.benchmarks.send_recv --backend ucp-core --n-bytes 1MiB --n-iter 100 --no-detailed-report --report-gil-contention
...
GIL contention            | 0.1721574366092682

$ python -m ucp.benchmarks.send_recv --backend ucp-async --n-bytes 1MiB --n-iter 100 --no-detailed-report --report-gil-contention
...
GIL contention            | 0.25215959548950195

$ UCXPY_NON_BLOCKING_MODE=1 python -m ucp.benchmarks.send_recv --backend ucp-async --n-bytes 1MiB --n-iter 100 --no-detailed-report --report-gil-contention
...
GIL contention            | 0.2693021595478058

Large messages (1 GiB)
$ python -m ucp.benchmarks.send_recv --backend ucp-core --n-bytes 1 GiB --n-iter 10 --no-detailed-report --report-gil-contention
...
GIL contention            | 0.5908554792404175

$ python -m ucp.benchmarks.send_recv --backend ucp-async --n-bytes 1GiB --n-iter 10 --no-detailed-report --report-gil-contention
...
GIL contention            | 0.6251853108406067

$ UCXPY_NON_BLOCKING_MODE=1 python -m ucp.benchmarks.send_recv --backend ucp-async --n-bytes 1GiB --n-iter 10 --no-detailed-report --report-gil-contention
...
GIL contention            | 0.832139790058136

Add argument to measure and report GIL contention in benchmarks. This
may provide some useful insight when optimizing asyncio-related changes.
@pentschev pentschev requested a review from a team as a code owner March 24, 2023 12:30
@quasiben
Copy link
Member

This is really cool! Can you describe what the output results are ? Is it time, a ratio, etc ?

@pentschev
Copy link
Member Author

It is a ratio of the perceived time the user code (in this case, UCX-Py send/recv messages) had the GIL. Thus 0.0 would mean the user code never took the GIL, whereas 1.0 would mean the user code had the GIL for the entirety of time without releasing it.

@jacobtomlinson
Copy link
Member

jacobtomlinson commented Mar 24, 2023

This looks neat! The Dask dashboard has a plot for this too, it's under the "more" list and is called "Contention". There were some performance implications with gilknocker==0.3.0 but seems much better in 0.4.0.

@pentschev
Copy link
Member Author

This looks neat! The Dask dashboard has a plot for this too, it's under the "more" list and is called "Contention". There were some performance implications with gilknocker==0.3.0 but seems much better in 0.4.0.

Yes, Ben pointed me to that, and that's where I stole the idea from.

@pentschev pentschev changed the base branch from branch-0.31 to branch-0.35 October 13, 2023 08:04
@copy-pr-bot
Copy link

copy-pr-bot bot commented Oct 13, 2023

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@pentschev
Copy link
Member Author

/ok to test

Copy link
Contributor

@wence- wence- left a comment

Choose a reason for hiding this comment

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

Minor nits, looks good though.

Interested to know how contended things are.

ucp/benchmarks/backends/tornado.py Outdated Show resolved Hide resolved
ucp/benchmarks/backends/ucp_core.py Outdated Show resolved Hide resolved
ucp/benchmarks/send_recv.py Outdated Show resolved Hide resolved
@pentschev
Copy link
Member Author

Interested to know how contended things are.

Not sure if you mean something different, but I reported contention numbers in the description. Did you overlook that or are you asking for something else?

@pentschev
Copy link
Member Author

/ok to test

@wence-
Copy link
Contributor

wence- commented Oct 13, 2023

Interested to know how contended things are.

Not sure if you mean something different, but I reported contention numbers in the description. Did you overlook that or are you asking for something else?

Oh no, I'm just blind...

@pentschev
Copy link
Member Author

Thanks @wence- !

@pentschev
Copy link
Member Author

/merge

@rapids-bot rapids-bot bot merged commit 9c17700 into rapidsai:branch-0.35 Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants