Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Of course writing into a file at each iteration is inefficient and most likely slow down your computing. (as a rule of thumb, depends on your actuel case)</p> <p>You have to use a <a href="http://en.wikipedia.org/wiki/Producer-consumer_problem" rel="nofollow"><em>producer</em> -> <em>consumer</em></a> design pattern. They will be linked by a queue, like a conveyor belt.</p> <ul> <li>The producer will try to produce as fast as it can, only slowing if the consumer can't handle it.</li> <li>The consumer will try to "consume" as fast as it can.</li> </ul> <p>By splitting the two, you can increase performance more easily because each process is simpler and has less interferences from the other.</p> <ul> <li>If the producer is faster, you need to improve the consumer, in your case by writing into file in the most efficient way, chunk by chunk most likely (as you said)</li> <li>If the consumer is faster, you need to improve the producer, most likely by parallelizing it as you said.</li> </ul> <p>There is <strong>no need</strong> to optimize both. Only optimize the slowest (the bottleneck).</p> <p>Practically, you use threads and a synchronized queue between them. For implementation hints, have a look <a href="http://www.quantnet.com/cplusplus-multithreading-boost/" rel="nofollow">here</a>, especially §18.12 "The Producer-Consumer Pattern".</p> <p>About flow management, you'll have to add a little bit more complexity by selecting a "max queue size" and making the producer(s) wait if the queue has not enough space. Beware of deadlocks then, code it carefully. (see the wikipedia link I gave about that)</p> <p>Note : It's a good idea to use boost threads because threads are not very portable. (well, they are since C++0x but C++0x availability is not yet good)</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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