question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Core] [Bug] ray.util.multiprocessing.Pool slower than multiprocessing.Pool

See original GitHub issue

Search before asking

  • I searched the issues and found no similar issues.

Ray Component

Others

What happened + What you expected to happen

I checked the efficiency of ray.util.multiprocessing.Pool and found that locally it is slower than multiprocessing.Pool I tested with Ray 1.6.0 Python 3.6.9 linux.

Code: `

import os import time import numpy as np from ray.util.multiprocessing import Pool as RPool from multiprocessing import Pool as MPool import ray

def f(index: int): return np.log2(index + 1) + np.log10(index + 1)

if name == ‘main’:

  ray.init()
  s = time.time()
  pool = RPool()
  results = list(pool.map(f, range(1000)))
  print(len(results))
  print('RPool', time.time() - s)
  ray.shutdown()

  s = time.time()
  pool = MPool()
  results = list(pool.map(f, range(1000)))
  print(len(results))
  print('MPool', time.time() - s)

`

Output was:
1000 RPool 0.8084681034088135 1000 MPool 0.03540182113647461

Versions / Dependencies

Ray 1.6.0 Python 3.6.9 linux.

Reproduction script

import os import time

import numpy as np from ray.util.multiprocessing import Pool as RPool from multiprocessing import Pool as MPool

import ray

def f(index: int): return np.log2(index + 1) + np.log10(index + 1)

if name == ‘main’: ray.init() s = time.time() pool = RPool() results = list(pool.map(f, range(1000))) print(len(results)) print(‘RPool’, time.time() - s) ray.shutdown()

s = time.time()
pool = MPool()
results = list(pool.map(f, range(1000)))
print(len(results))
print('MPool', time.time() - s)

Anything else

Every run.

Are you willing to submit a PR?

  • Yes I am willing to submit a PR!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
yogeverancommented, Jan 5, 2022

Ray version 1.9.1 and 2.0.0.dev0 still suffers with a ~4 slowdown (ran on google colab). Python 3.7.12

0reactions
stale[bot]commented, Sep 20, 2022

Hi again! The issue will be closed because there has been no more activity in the 14 days since the last message.

Please feel free to reopen or open a new issue if you’d still like it to be addressed.

Again, you can always ask for help on our discussion forum or Ray’s public slack channel.

Thanks again for opening the issue!

Read more comments on GitHub >

github_iconTop Results From Across the Web

multiprocessing.Pool() slower than just using ordinary functions
Pool.map is slower because it takes time to start the processes and then transfer the necessary memory from one to all processes as ......
Read more >
Ray component: Core: PoolActor processes hanging #24784
util.multiprocessing.Pool to manage all of the processes across the nodes was slower than just using multiprocessing.Pool on a single node.
Read more >
10x Faster Parallel Python Without Python Multiprocessing
The multiprocessing version is slower because it needs to reload the model in every map call because the mapped functions are assumed to...
Read more >
Distributed multiprocessing.Pool — Ray 2.2.0
Ray supports running distributed python programs with the multiprocessing. Pool API using Ray Actors instead of local processes. This makes it easy to...
Read more >
Why your multiprocessing Pool is stuck (it's full of sharks!)
On Linux, the default configuration of Python's multiprocessing library can lead to deadlocks and brokenness. Learn why, and how to fix it.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found