Weirdo multiprocessing: Shared objects taking more time in sharing smaller data than larger data between multiple processes.
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug report
Bug description:
server.py
from multiprocessing.managers import BaseManager
from queue import Queue
queue = Queue()
class QueueManager(BaseManager): pass
QueueManager.register('get_queue', callable=lambda:queue)
m = QueueManager(address=('', 5000), authkey=b'abracadabra')
s = m.get_server()
s.serve_forever()
consumer.py
import time
from multiprocessing.managers import BaseManager
class QueueManager(BaseManager): pass
QueueManager.register('get_queue')
m = QueueManager(address=('', 5000), authkey=b'abracadabra')
m.connect()
queue = m.get_queue()
while True:
t = time.time()
x = queue.get()
producerA.py
from multiprocessing.managers import BaseManager
import time
import numpy as np
class QueueManager(BaseManager): pass
QueueManager.register('get_queue')
m = QueueManager(address=('', 5000), authkey=b'abracadabra')
m.connect()
queue = m.get_queue()
out_img = np.zeros((128, 128, 3), dtype=np.uint8)
for i in range(100):
t = time.time()
queue.put(
{
'type' : 'not working',
'data': out_img
}
)
print('put took', (time.time() - t)*1000)
producerB.py
from multiprocessing.managers import BaseManager
import time
import numpy as np
class QueueManager(BaseManager): pass
QueueManager.register('get_queue')
m = QueueManager(address=('', 5000), authkey=b'abracadabra')
m.connect()
queue = m.get_queue()
out_img = np.zeros((256, 256, 3), dtype=np.uint8)
for i in range(100):
t = time.time()
queue.put(
{
'type' : 'not working',
'data': out_img
}
)
print('put took', (time.time() - t)*1000)
steps to reproduce the issue
- run
server.py - run
consumer.py - run
producerA.pyand check theput timeand compare it withproducerB.pyput time.
put time in producerA.py is higher than producerB.py, however the size of data being send through shared queue objects is more in producerB.py( 256x256 ) than in producerA.py (128x128).
I don't have much context if this is related to numpy or cpython multiprocessing, but this is definitely shouldn't be the case.
Ideally it should take more time in producerB.py beacuase the size of data is relatively higher relative to producerA.py.
This is my first bug report, I'm hoping to learn something...
Thanks everyone...
CPython versions tested on:
3.10
Operating systems tested on:
Linux
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo server.py e consumer.py, quindi confronta i tempi di producerA.py e producerB.py sulla configurazione Linux e CPython 3.10 indicata. Traccia il comportamento attraverso la multiprocessing manager queue e i percorsi di serializzazione NumPy di CPython. Il report non indica alcun file sorgente né alcun target di test, quindi per completare il lavoro sono necessarie una causa confermata e una risoluzione appropriata per il progetto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- numpy, python
- Ambito
- distributed-systems
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100