Abdelrazak Younes <you...@lyx.org> writes:

| On 07/11/2011 10:22, Tommaso Cucinotta wrote:
>> Hi,
>>
>> I just "enjoyed" extending the Find Advanced feature to exploit
>> multi-cores.
>
| What about enjoying to implement the correct solution for the advanced
| find feature? I'm sure you'll much more fun :-P
>
>> It exploits QThreadPool to create "worker" threads (as many as the
>> underlying
>> physical CPUs detected by QThreadPool). Each thread searches in a single
>> paragraph, then "queries" the next paragraph to be searched from a
>> common synchronized "monitor" (see FindAdvHits::nextRange()), then
>> keeps going. In the end, the
>> first logically sequential match is returned (i.e., no alteration on the
>> current behavior/semantics of Find Advanced). So, if a thread searching
>> later paragraphs finds a hit while another thread that is searching prior
>> paragraphs is still searching, then the result delivery will wait
>> till the
>> latter one either finds nothing, or it finds its own match (which will be
>> returned, in this case).
>>
>> From a preliminary/rough test, finding "The above bib" in UserGuide.lyx
>> (matching on the very last sentence of the document), takes
>> -) 15 secs with the current trunk
>> -) 8 secs with this patch applied
>
| I am ready to bet that it will be even quicker with a single thread if
| you implement the feature correctly... and by that I mean searching
| the binary structure.

Depends on the size of the structure. You can parallelize searches in
trees and graphs. You can even get into super-linear territory if you
are lucky with the dataset.

Reply via email to