Open
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1779 +/- ##
==========================================
+ Coverage 94.21% 94.27% +0.05%
==========================================
Files 46 48 +2
Lines 7922 8070 +148
==========================================
+ Hits 7464 7608 +144
- Misses 458 462 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Contributor
Author
|
For a perf comparison, it's possible to use the example from #1733 import concurrent
import concurrent.futures
import itertools
import time
import joblib
import pyvista as pv
def process(mesh: pv.PolyData, idx: int) -> float:
"""A simple function that accesses data from the mesh."""
return mesh.points[idx, 0]
def process2(mesh, idx):
return process(mesh.result(), idx)
def main() -> None:
# Create a large mesh object to demonstrate the issue.
# A smaller `level` will reduce the mesh size and the performance gap.
mesh: pv.PolyData = pv.Box(level=200)
N_JOBS: int = 1000
print("Mesh details:")
print(mesh)
print("-" * 20)
# Benchmark joblib with automatic batching
with joblib.parallel_config(n_jobs=8, verbose=1, prefer="processes"):
time_start: float = time.perf_counter()
shelved_mesh = joblib.shelve(mesh)
parallel = joblib.Parallel()
_ = parallel(joblib.delayed(process2)(shelved_mesh, i) for i in range(N_JOBS))
shelved_mesh.clear()
time_end: float = time.perf_counter()
rate: float = N_JOBS / (time_end - time_start)
print(f"joblib (with shelving): {rate:.2f} it/sec")
time_start: float = time.perf_counter()
parallel = joblib.Parallel()
_ = parallel(joblib.delayed(process)(mesh, i) for i in range(N_JOBS))
time_end: float = time.perf_counter()
rate: float = N_JOBS / (time_end - time_start)
print(f"joblib: {rate:.2f} it/sec")
# Benchmark concurrent.futures.ProcessPoolExecutor
time_start = time.perf_counter()
with concurrent.futures.ProcessPoolExecutor(max_workers=8) as executor:
_ = executor.map(
process,
itertools.repeat(mesh),
range(N_JOBS),
chunksize=N_JOBS // 16,
)
time_end = time.perf_counter()
rate: float = N_JOBS / (time_end - time_start)
print(f"concurrent.futures: {rate:.2f} it/sec")
if __name__ == "__main__":
main() |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR is an attempts to address #593.
This PR is based on an existing PR #619.
clearis used or when the owningShelfis closed. AShelfis closed when the program ends or when theclosemethod is used. AShelfobject can also be used as a context withwith. The__exit__method ofShelfcloses the shelf and hence remove all files containing the shelved objects.shelve_mmap. I would say that users could create their own memmap and it does not seem to me that much related to "basic" shelving.Example:
Closes: #593
Closes: #996
Closes: #1733