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

Fix for the v-packet logging while parallelism is enabled. #1647

Merged
merged 1 commit into from
Jun 14, 2021

Conversation

Rodot-
Copy link
Contributor

@Rodot- Rodot- commented Jun 14, 2021

Enabling V-Packet logging while the number of threads is set to a value greater than 1 causes the Python kernel to crash. This PR fixes this issue.

The issue stems from trying to append to default Python lists inside a parallel loop in numba (using prange). To avoid multiple threads allocating new memory on the same objects at the same time, I instead cache all vpacket collections ahead of the main loop in a numba typed list. After the main loop, the relevant packet information is extracted back out to create the logging arrays. The vpacket collection caching will always happen even if logging is disabled, but the extraction of the data is not. A potential caveat of this is that there may be more memory usage when a large number of vpackets is requested than normal. This change adds a little less than a second of run time as the instantiation of the vpacket collections and their data retrieval is no longer performed in parallel.

This PR is meant to resolve issue #1614

Motivation and context
The kernel would crash when vpacket logging was enabled with more than 1 thread.

How has this been tested?

Type of change

  • Bug fix.
  • New feature.
  • Breaking change.
  • None of the above.

Checklist

  • My change requires a change to the documentation.
    • I have updated the documentation accordingly.
    • (optional) I have built the documentation on my fork following the instructions.
  • I have assigned and requested two reviewers for this pull request.

…acket collections are cached at the start of the loop and data is extracted afterwards
@Rodot- Rodot- requested a review from marxwillia June 14, 2021 14:33
@tardis-bot
Copy link
Contributor

Before a pull request is accepted, it must meet the following criteria:

  • Is the necessary information provided?
  • Is this a duplicate PR?
    • If a new PR is clearly a duplicate, ask how this PR is different from the original PR?
    • If this PR is about to be merged, close the original PR with a link to this new PR that solved the issue.
  • Does it pass existing tests and are new tests provided if required?
    • The test coverage should not decrease, and for new features should be close to 100%.
  • Is the code tidy?
    • No unnecessary print lines or code comments.

@Rodot- Rodot- linked an issue Jun 14, 2021 that may be closed by this pull request
2 tasks
@codecov
Copy link

codecov bot commented Jun 14, 2021

Codecov Report

Merging #1647 (4f52685) into master (7e4631c) will decrease coverage by 0.06%.
The diff coverage is n/a.

❗ Current head 4f52685 differs from pull request most recent head d169166. Consider uploading reports for the commit d169166 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1647      +/-   ##
==========================================
- Coverage   67.13%   67.07%   -0.07%     
==========================================
  Files          73       73              
  Lines        6100     6107       +7     
==========================================
+ Hits         4095     4096       +1     
- Misses       2005     2011       +6     
Impacted Files Coverage Δ
tardis/tardis/montecarlo/montecarlo_numba/base.py 28.73% <0.00%> (-1.27%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d3ff053...d169166. Read the comment docs.

@Rodot- Rodot- requested a review from andrewfullard June 14, 2021 14:41
@andrewfullard andrewfullard linked an issue Jun 14, 2021 that may be closed by this pull request
@Rodot- Rodot- changed the title Fix for the v-packet logging while parallelism is enbaled. Fix for the v-packet logging while parallelism is enabled. Jun 14, 2021
@wkerzendorf wkerzendorf merged commit 8aec326 into master Jun 14, 2021
atharva-2001 pushed a commit to atharva-2001/tardis that referenced this pull request Oct 1, 2021
…acket collections are cached at the start of the loop and data is extracted afterwards (tardis-sn#1647)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Virtual Logging & Nthreads Kernel crashes when nthreads > 1
4 participants