Merge lp:~submarine/ubuntu-scopes/devhelp-50-results-limit into lp:~submarine/ubuntu-scopes/devhelp

Proposed by David Callé
Status: Merged
Approved by: James Henstridge
Approved revision: 19
Merged at revision: 18
Proposed branch: lp:~submarine/ubuntu-scopes/devhelp-50-results-limit
Merge into: lp:~submarine/ubuntu-scopes/devhelp
Diff against target: 35 lines (+12/-1)
1 file modified
src/unity_devhelp_daemon.py (+12/-1)
To merge this branch: bzr merge lp:~submarine/ubuntu-scopes/devhelp-50-results-limit
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
James Henstridge Approve
Review via email: mp+154539@code.launchpad.net

Commit message

Limit the number of results to 50.

Description of the change

Limit the number of results to 50.

To post a comment you must log in.
Revision history for this message
James Henstridge (jamesh) wrote :

Is the purpose of this branch to try and improve performance, or just to limit the result count?

While this certainly does limit the search results to 50 hits, it looks like it is still doing approximately the same amount of work (I assume scanning the /usr/share/gtk-doc/html tree and running an XML parser on each .devhelp file is the slow point).

If performance is the issue, then perhaps one of the following would help:

1. make setup_devhelp() a generator, so exiting the loop early will cut the scanning work short.

2. cache the results of setup_devhelp() between searches.

Either way, a linear scan of the keywords found in the .devhelp file seems awfully slow.

Revision history for this message
James Henstridge (jamesh) :
review: Needs Information
Revision history for this message
David Callé (davidc3) wrote :

Performance is not really the issue, but the fast that it can return up to ~15 000 results in the Dash feels a bit overwhelming when looking for help.

Nevertheless, I will add the suggested improvements to this merge.

19. By David Callé

Speed up results

Revision history for this message
David Callé (davidc3) wrote :

I've added a bit of caching and not querying for one letter searches. The next step will be to improve the quality of results with libcolumbus, but it can land later IMHO.

Revision history for this message
James Henstridge (jamesh) wrote :

Sounds good.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/unity_devhelp_daemon.py'
2--- src/unity_devhelp_daemon.py 2013-03-19 22:20:08 +0000
3+++ src/unity_devhelp_daemon.py 2013-03-21 10:08:24 +0000
4@@ -51,6 +51,7 @@
5
6 EXTRA_METADATA = []
7
8+CACHE_DEVHELP = None
9
10 def setup_devhelp():
11 '''
12@@ -101,12 +102,22 @@
13 Search for help documents matching the search string
14 '''
15 results = []
16- devhelp = setup_devhelp()
17+ if len(search) < 2:
18+ return results
19+ global CACHE_DEVHELP
20+ if not CACHE_DEVHELP:
21+ print("Loading results...")
22+ devhelp = setup_devhelp()
23+ CACHE_DEVHELP = devhelp
24+ else:
25+ devhelp = CACHE_DEVHELP
26 icon_hint = Gio.ThemedIcon.new("text-x-generic").to_string()
27 for data in devhelp:
28 if os.path.exists("/usr/lib/unity-lens-help/icons/%s.svg" % data[2]):
29 icon_hint = "/usr/lib/unity-lens-help/icons/%s.svg" % data[2]
30 if search.lower() in data[0].lower():
31+ if len(results) >= 50:
32+ break
33 results.append({'uri': data[0],
34 'icon': icon_hint,
35 'category': 0,

Subscribers

People subscribed via source and target branches

to all changes: