r/datascience • u/hadley • 29d ago
Tools mizu: a new tool to speed up parallel data science workflows
(I’m Hadley Wickham, Chief Scientist at Posit and I’m posting this for my colleague Charlie Gao (u/shikokuchuo) who doesn't have enough karma to post here 🤣).
Resampling (bootstrap, cross-validation, ...) is a common part of modelling that takes a long time and in principle should be trivially parallelisable. Unfortunately, in reality the speedup is usually well short of the allocated cores. The reason is how the process pool has to distribute work: each task is serialized, copied through a socket then deserialized on the other side, and each result has to come back the same way. This has two problems: when tasks are small the overhead can exceed the computation, and when the data is large every worker holding a copy exhausts memory.
Charlie has come up with a new solution using shared memory. pymizu (Python) and mizu (R) use shared memory to parallelise work. The data for each task is written once into memory that the scheduler and worker share, so the worker reads it without copying. Compared to using sockets (the current fastest approach) a round trip drops from about 100 µs to under 1 µs (measured on an Apple M4 Pro). And this makes a difference for data science workflows: four typical tidymodels workloads chosen to stress data movement relative to compute, 12 mizu workers gave 6.7–8.1x speedups versus 1.4–6.4x for mirai, already the most performant parallel framework in R.
In Python, pymizu is a drop-in replace for theconcurrent.futuresexecutor, and NumPy arrays and polars/pyarrow/pandas frames cross between processes without any copies. pymizu and mizu are designed to work together for cross-language workflows. Each can launch workers in either language, so a data frame in an R session can cross to a Python worker as an Arrow-backed frame, and the polars result comes back as an R data frame.
More details, benchmarks, and examples are available at: https://opensource.posit.co/blog/2026-11-05_mizu-0-1-0/ or get started with
pip install pymizu / install.packages("mizu").
140
u/CityInternational605 29d ago
What seriously Hadley Wickham the GOAT himself?
10
u/HazardCinema 29d ago
tidyverse is the foundation of my early DS career. Just want to say thank you. I'm barely coding live anymore but I'll always appreciate the fundamentals your libraries taught me.
20
u/lhrad 29d ago
In Hungarian "mizu?" means sth like"wazzup?", lol.
11
u/Deto 29d ago
I'm curious if you've compared this to
joblibon the python side?11
u/Key-Accident2075 29d ago
Very interesting. Just the other day, I was musing how R is sort of inefficient when it comes to parallelisation and then you guys drop mizu.
Congrarulation to the team. Will check it out next week!
5
u/Delicious-View-8688 29d ago
Be water my friend. Will check it out. Thanks!
5
u/burtcopaint 29d ago
Wow, nice to see you.
I still hate that Twitter to X transition. Lost so much good info...
4
u/Psychological-Fox178 29d ago
Very cool!
6
u/Zeiramsy 29d ago
Off-topic but your video showing your DS workflow on house price modelling basically started my whole DS career, one of the most insightful DS videos I ever saw.
This looks really interesting.
3
u/fourthwaiv 29d ago
3
u/Oh_Petya 29d ago
This is perfect timing! A project I am working on involves a specification analysis of 766 models where I evaluate each one under time series cross-validation (i.e. evaluating on a rolling origin) across 371 origins, so I'm fitting models 284186 times! I'm currently using furrr to parallelize it on my server and I can get the cross-validations done in about 12 hours.
I'll give this a try and see how much it speeds it up and improves memory usage. I have to dip into swap memory frequently with my current method.
2
u/horapdethap 29d ago
A while ago I tried this with dask, persisting a big dataframe scattered across cluster nodes for tasks to share (https://distributed.dask.org/en/stable/memory.html#persisting-collections) but still got out of memory errors. Excited to try this
Any plans for making massively scalable permutation tests as a function you can just call?
2
u/Ok-Introduction9593 29d ago
Cool concept. Are there any gotchas when working with custom Python objects? Or does the zero-copy magic only apply to numpy and arrow backends?
1
u/pneumatics 26d ago
Hi Hadley, wasn’t this the original motivation for you and Wes McKinney developing arrow? Zero copy in-memory interop between R and Python? How is mizu different?
1
u/simonpcouch 23d ago
Super excited about this one! More performant than mirai is wild, especially by this margin.
1
u/ApplicationFar2400 19d ago
This looks promising! The focus on shared memory for parallelization really addresses the traditional bottlenecks we face with resampling tasks. Seeing 6.7–8.1x speedups in typical tidymodels workloads compared to existing frameworks is impressive. I’m especially intrigued by how pymizu integrates so seamlessly with Python tools, allowing for efficient data frame exchanges without the overhead of copying. It could really streamline workflows across languages.