Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat profiling do I need to do to optimize a multi-step producer-consumer model?
    primarykey
    data
    text
    <p>I have a 3-step producer/consumer setup.</p> <p><code>Client</code> creates JSON-encoded dictionaries and sends them to <code>PipeServer</code> via a named pipe</p> <p>Here are my threading.Thread subclasses:</p> <p><code>PipeServer</code> creates a named pipe and places messages into a queue <code>unprocessed messages</code></p> <p><code>Processor</code> gets items from <code>unprocessed messages</code>, processes them (via a lambda function argument), and puts them into a queue <code>processed messages</code></p> <p><code>Printers</code> gets items from <code>processed messages</code>, acquires a lock, prints the message, and releases the lock.</p> <p>In the test script, I have one PipeServer, one Processor, and 4 Printers:</p> <pre><code>pipe_name = '\\\\.\\pipe\\testpipe' pipe_server = pipetools.PipeServer(pipe_name, unprocessed_messages) json_loader = lambda x: json.loads(x.decode('utf-8')) processor = threadedtools.Processor(unprocessed_messages, processed_messages, json_loader) print_servers = [] for i in range(4): print_servers.append(threadedtools.Printer(processed_messages, output_lock, 'PRINTER {0}'.format(i))) pipe_server.start() processor.start() for print_server in print_servers: print_server.start() </code></pre> <p>Question: in this kind of multi-step setup, how do I think through optimizing the number of Printer vs. Processor threads I should have? For example, how do I know if 4 is the optimal number of Printer threads to have? Should I have more processors?</p> <p>I read through the Python Profilers docs, but didn't see anything that would help me think through these kinds of tradeoffs.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload