From kwrite-devel Mon Feb 24 08:58:39 2014 From: "Milian Wolff" Date: Mon, 24 Feb 2014 08:58:39 +0000 To: kwrite-devel Subject: Re: Review Request 115976: Wildcard-like search string + edit distance-based sorting for Quick Open Message-Id: <20140224085839.25983.80339 () probe ! kde ! org> X-MARC-Message: https://marc.info/?l=kwrite-devel&m=139323234016746 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============6878012903066273935==" --===============6878012903066273935== Content-Type: multipart/alternative; boundary="===============0968966778913544630==" --===============0968966778913544630== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit > On Feb. 23, 2014, 6:57 p.m., Sven Brauch wrote: > > We're starting to have a lot of those algorithms now -- kdevelop has one for quickopen, kate has one for the completion list and now one for quickopen too. Maybe we could determine some shared functionality and put it in KTextEditor for all three places to re-use? We'd just need to discus what functionality that would be. > > > > Apart from that, my experience from kdevelop's quickopen is that arbitrary distance of characters easily yields weird results when applied to longer paths. But maybe that's fixed by your sorting algorithm. > > > > Does kate's quickopen filter all files when you have a project open, or always just open files? In the former case, is the regex approach fast enough? > > Kirill Bogdanenko wrote: > > Does kate's quickopen filter all files when you have a project open, or always just open files? In the former case, is the regex approach fast enough? > > quickopen filter is applied to all documents that are available, these are: > 1. Views > 2. Opened documents > 3. Project files > (for details see KateQuickOpen::update method in kate/app/katequickopen.cpp) > > In the case regex approach is fast enough (but actually can be replaced by wildcard otherwise). At least I hadn't experienced any slowdowns on kate.git project on my laptop (dual-core i7-2640M, 8 GiB RAM). But I haven't done any real benchmarks. > > Kirill Bogdanenko wrote: > ... but probably it's worth to override filter's filterAcceptsRow() method and get rid of regexp matching. > > Algorhithm can be like as follows: > > int lastPos = -1; > > for (int i = pattern.length() - 1; i >= 0; i--) { > int pos = candidate.lastIndexOf(pattern[i], lastPos); > if (pos != -1) { > lastPos = pos; > } else { > return false; > } > } > > Can you advice some benchmarking tool that will help to compare these approaches? > > Sven Brauch wrote: > Milian is the resident expert on benchmarks around here, but if you write a unit test (which is always awesome anyways) you can easily use QBENCHMARK to compare the approaches. A simpler method is just putting QTime t; t.start; [do stuff] qDebug() << t.elapsed() around your code. > More serious benchmarking can use valgrind --tool=cachegrind or intel's vtune, but I doubt that's worth it in this case. Jup, a QBENCHMARK would be greatly appreciated. QElapsedTimer based "profiling" is only a good tool to quickly verify hotspots found by other means, such as perf, callgrind or vtune. A QBENCHMARK is still needed in order to systematically improve performance and ensure that no performance regressions creep in. - Milian ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://git.reviewboard.kde.org/r/115976/#review50608 ----------------------------------------------------------- On Feb. 23, 2014, 6:44 p.m., Kirill Bogdanenko wrote: > > ----------------------------------------------------------- > This is an automatically generated e-mail. To reply, visit: > https://git.reviewboard.kde.org/r/115976/ > ----------------------------------------------------------- > > (Updated Feb. 23, 2014, 6:44 p.m.) > > > Review request for Kate, Christoph Cullmann and Dominik Haumann. > > > Bugs: 328569 > http://bugs.kde.org/show_bug.cgi?id=328569 > > > Repository: kate > > > Description > ------- > > Wildcard-like search string for Quick Open > > * Search string turns into regexp like: > > foo -> /f.*o.*o.*$/ > > (special characters in original pattern are escaped) > > * Filtered items are sorted using edit (Levenstein) distance > > > Diffs > ----- > > kate/app/CMakeLists.txt f39bf68 > kate/app/katequickopen.h 175826e > kate/app/katequickopen.cpp 235f9f1 > kate/app/katequickopenproxymodel.h PRE-CREATION > kate/app/katequickopenproxymodel.cpp PRE-CREATION > > Diff: https://git.reviewboard.kde.org/r/115976/diff/ > > > Testing > ------- > > > Thanks, > > Kirill Bogdanenko > > --===============0968966778913544630== Content-Type: text/html; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit
This is an automatically generated e-mail. To reply, visit: https://git.reviewboard.kde.org/r/115976/

On February 23rd, 2014, 6:57 p.m. UTC, Sven Brauch wrote:

We're starting to have a lot of those algorithms now -- kdevelop has one for quickopen, kate has one for the completion list and now one for quickopen too. Maybe we could determine some shared functionality and put it in KTextEditor for all three places to re-use? We'd just need to discus what functionality that would be.

Apart from that, my experience from kdevelop's quickopen is that arbitrary distance of characters easily yields weird results when applied to longer paths. But maybe that's fixed by your sorting algorithm.

Does kate's quickopen filter all files when you have a project open, or always just open files? In the former case, is the regex approach fast enough?

On February 23rd, 2014, 10:26 p.m. UTC, Kirill Bogdanenko wrote:

> Does kate's quickopen filter all files when you have a project open, or always just open files? In the former case, is the regex approach fast enough?

quickopen filter is applied to all documents that are available, these are:
1. Views
2. Opened documents
3. Project files
(for details see KateQuickOpen::update method in kate/app/katequickopen.cpp)

In the case regex approach is fast enough (but actually can be replaced by wildcard otherwise). At least I hadn't experienced any slowdowns on kate.git project on my laptop (dual-core i7-2640M, 8 GiB RAM). But I haven't done any real benchmarks.

On February 23rd, 2014, 10:48 p.m. UTC, Kirill Bogdanenko wrote:

... but probably it's worth to override filter's filterAcceptsRow() method and get rid of regexp matching.

Algorhithm can be like as follows:

  int lastPos = -1;

  for (int i = pattern.length() - 1; i >= 0; i--) {
      int pos = candidate.lastIndexOf(pattern[i], lastPos);
      if (pos != -1) {
          lastPos = pos;
      } else {
          return false;
      }
  }

Can you advice some benchmarking tool that will help to compare these approaches?

On February 23rd, 2014, 11:39 p.m. UTC, Sven Brauch wrote:

Milian is the resident expert on benchmarks around here, but if you write a unit test (which is always awesome anyways) you can easily use QBENCHMARK to compare the approaches. A simpler method is just putting QTime t; t.start; [do stuff] qDebug() << t.elapsed() around your code.
More serious benchmarking can use valgrind --tool=cachegrind or intel's vtune, but I doubt that's worth it in this case.
Jup, a QBENCHMARK would be greatly appreciated. 

QElapsedTimer based "profiling" is only a good tool to quickly verify hotspots found by other means, such as perf, callgrind or vtune. A QBENCHMARK is still needed in order to systematically improve performance and ensure that no performance regressions creep in.

- Milian


On February 23rd, 2014, 6:44 p.m. UTC, Kirill Bogdanenko wrote:

Review request for Kate, Christoph Cullmann and Dominik Haumann.
By Kirill Bogdanenko.

Updated Feb. 23, 2014, 6:44 p.m.

Bugs: 328569
Repository: kate

Description

Wildcard-like search string for Quick Open

* Search string turns into regexp like:

    foo -> /f.*o.*o.*$/

  (special characters in original pattern are escaped)

* Filtered items are sorted using edit (Levenstein) distance

Diffs

  • kate/app/CMakeLists.txt (f39bf68)
  • kate/app/katequickopen.h (175826e)
  • kate/app/katequickopen.cpp (235f9f1)
  • kate/app/katequickopenproxymodel.h (PRE-CREATION)
  • kate/app/katequickopenproxymodel.cpp (PRE-CREATION)

View Diff

--===============0968966778913544630==-- --===============6878012903066273935== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ KWrite-Devel mailing list KWrite-Devel@kde.org https://mail.kde.org/mailman/listinfo/kwrite-devel --===============6878012903066273935==--