-
Notifications
You must be signed in to change notification settings - Fork 228
Add common alias cores (x) for grdlandmask #2944
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
54577a8
Add common alias cores (x) for grdlandmask
weiji14 137a04f
Run test_grdlandmask_no_outgrid with 2 cores
weiji14 b8b10fd
Merge branch 'main' into limit-cores
weiji14 35e2d61
Try setting cores=1 and turn on verbose info mode
weiji14 ce4901c
Merge branch 'main' into limit-cores
weiji14 97637d4
Revert "Try setting cores=1 and turn on verbose info mode"
weiji14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Linux runner for GitHub Actions has 2 CPU cores according to https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources, but not sure if we should set cores to 2 or 1 for consistent benchmarking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using two cores is faster and can help check the OpenMP feature in GMT, so I prefer to use two cores if possible.
BTW, the macOS runner for GitHub Actions has 3 cores, so instead of
cores=2
,cores=True
will use all available cores.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is only 1 core being used if we don't set
cores
, or usecores=None
? I'm reading https://docs.generic-mapping-tools.org/6.4/gmt.html#core-full which says[default is to use all available cores]
, but is that only withcores=True
(i.e.-x
in GMT)?The
benchmark.yml
workflow is running on Linux, but I guess we could setcores=True
since this test would also run on macOS inci_test.yml
. My question was more around whether multi-threading with multiple-cores (2 or more) would provide a consistent benchmark compared to using only 1 core, but I guess we need to merge this PR to find out!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it uses all available cores if
-x
is not used.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
test_grdlandmask_no_outgrid
benchmark speedup went from 3x to 9.6x 🤣 It might be that there is some overhead with using threading (2 cores) vs no threading (1 core). Here's the flame graph diff from https://codspeed.io/GenericMappingTools/pygmt/branches/limit-cores again:The extra
gomp_team_barrier_wait_*
calls are still there, but also some other stuff (in blue).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reminds me of the warnings message I saw when running the tests in random order (see https://github.com/GenericMappingTools/pygmt/actions/runs/7396374248/job/20121388367?pr=2936):
There are some related discussions at https://discuss.python.org/t/concerns-regarding-deprecation-of-fork-with-alive-threads/33555 and related PR at python/cpython#100228.
Not sure if it's related to the issue here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That
test_session_multiprocessing
function is only runningbasemap
andsavefig
right? It shouldn't have any multi-threading going on, so not sure what's happening.I tried running some benchmarks using cores from -1 (all cores) to 0 (no-multithreading) to 16 (all cores on my laptop). This was running
grdlandmask
with a spacing of 0.05 arc degrees. The results do vary between runs, but in general, more cores means less time:Code to reproduce:
If I change the spacing from 0.05 arc degrees to 1 arc degree, more cores actually take more time:
For that
test_grdlandmask_no_outgrid
unit test which is usingspacing=1
(i.e. 1 arc degree), I think we should just usecores=2
, sincecores=3
might not be much faster on such a low resolution. As long as we are benchmarking with a fixed number of core counts, it should be ok?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, back to using
cores=2
in 97637d4.