Review Request: Implemented multithreading in KFileItemModelSortAlgorithm
Frank Reininghaus
frank78ac at googlemail.com
Fri Oct 26 11:25:46 BST 2012
> On Oct. 25, 2012, 4:47 p.m., Frank Reininghaus wrote:
> > Thanks for the new patch, looks good! I've added a few comments below which will might make the code less complex.
> >
> > Can you provide some benchmarks (i.e., sorting time for a fixed number of items with the current single-threaded implementation and for 2 and 4 threads)?
>
> Emmanuel Pescosta wrote:
> (Intel Core i5) Sorting 500.000 files with:
> # 1 Thread: 6450 ms, 6458 ms, 6567 ms -> Avr.: 6492 ms
> # 2 Threads: 4368 ms, 4327 ms, 4259 ms -> Avr.: 4318 ms
> # 4 Threads: 4164 ms, 4063 ms, 4076 ms -> Avr.: 4101 ms
Thanks! Are your 4 cores 'real' or hyper-threaded? I'm asking because it seems that there are some Core i5 models with 4 cores and some others with 2.
> On Oct. 25, 2012, 4:47 p.m., Frank Reininghaus wrote:
> > dolphin/src/kitemviews/private/kfileitemmodelsortalgorithm.cpp, line 29
> > <http://git.reviewboard.kde.org/r/107025/diff/3/?file=92347#file92347line29>
> >
> > I would not do any checks here - just determine numberOfThreads and call parallelSort().
> >
> > Right now, some parts are needlessly duplicated, like the "span < 2" check.
> >
> > I think that even the "span > 100" check is better moved to parallelSort() - consider the case that the sort interval is split a couple of times and gets very small - we want to fall back to sequentialSort() also in that case.
>
> Emmanuel Pescosta wrote:
> The "span > 100" check is needed in sort(), to avoid QThread::idealThreadCount() call.
If you're worried that the QThread::idealThreadCount() call is too expensive, I'd rather write
static const int numberOfThreads = QThread::idealThreadCount();
This guarantees that the function is called only once.
- Frank
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/107025/#review20892
-----------------------------------------------------------
On Oct. 25, 2012, 7:42 p.m., Emmanuel Pescosta wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://git.reviewboard.kde.org/r/107025/
> -----------------------------------------------------------
>
> (Updated Oct. 25, 2012, 7:42 p.m.)
>
>
> Review request for Dolphin and Frank Reininghaus.
>
>
> Description
> -------
>
> Implemented multithreading in KFileItemModelSortAlgorithm.
>
> If more than 100 items to sort and ideal thread count is greater than 1 -> sort them with parallelSort (2 Threads)
>
> Use maximal 2 Threads, because more than 2 Threads are "slower" (more overhead than speed up). (I also have a patch which uses n Threads for sorting, if you want test it ;)
>
>
> Diffs
> -----
>
> dolphin/src/kitemviews/private/kfileitemmodelsortalgorithm.h 3a596df
> dolphin/src/kitemviews/private/kfileitemmodelsortalgorithm.cpp e0aac13
>
> Diff: http://git.reviewboard.kde.org/r/107025/diff/
>
>
> Testing
> -------
>
> About 2 seconds faster with sorting 500.000 files.
> About 5 seconds faster with sorting 1.000.000 files.
>
>
> Thanks,
>
> Emmanuel Pescosta
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20121026/3d86ddf0/attachment.htm>
More information about the kfm-devel
mailing list