When modifying the search query (typing/replacing/deleting characters), automatically issue a cancel order to Tracker to interrupt previous/intermediate search queries everytime
As a complement to the merged improvements from issue nautilus#1731 (closed), to tackle a big remaining backend portion of the wider search performance problem (issue nautilus#246 (closed) and issue nautilus#620 (closed)), Nautilus should tell Tracker to cancel/interrupt existing/previous searches of the current search window everytime you modify the search query, exit the search, or use "Open item location
" on a search result), in order to reduce the impact and improve performance for the new/adjusted search.
Reportedly, Nautilus currently does not (as of version 43) do such "automatic search cancellations" yet (a short discussion on IRC confirmed that this is what we assume to be the case right now). If so, this should be done; nothing is lost from doing so, and it can only improve performance. #264 (closed) was implemented in Tracker to allow this to happen (possibly using Nautilus' nautilus_search_provider_stop
/ stop_search
methods¹, that presumably use a g_cancellable_cancel
somewhere down the line?) when the user manually exits a Nautilus search, but supposedly this trick in Nautilus wasn't extended to occur while typing/modifying/removing charaters in an active search query (?) or maybe there's a bug somewhere else²…
This would help cover the case of a slow typist, or someone who changes their mind multiple times along the way, or a system struggling to keep up with resource demands for search (because such performance problems can have a compounding effect). It is once again a part of the performance puzzle, one that is worth implementing and keeping no matter what other optimizations show up next, because anything that reduces the "computer does too much work for nothing" situation will improve performance and reduce power consumption.
Some ideas of potential ways to measure the impact (other than using sysprof?) in day-to-day usage:
- launch Nautilus and GNOME System Monitor side by side
- search for "Nautilus" in GNOME System Monitor's list of processes to filter down to Nautilus-related things
- launch a vague and slow search in Nautilus in your home directory with a 4-letter string / simple word
- as some results show up, keep typing or modifying the search query slowly
You should be able to observe that Tracker keeps on searching and eating the CPU and I/O more than it should.
Note that this is not the same thing as users manually cancelling searches (issue nautilus#1586 and nautilus#2393).
More end notes:
- ¹: I
git grep
'ed for those method names in Nautilus' codebase and had a vague look at the resulting files, and although I'm very far from being competent at understanding C code, nothing jumped at me as a stop action being connected to characters being typed. - ²: @carlosg mentioned there might be (theoretically speaking) a regression regarding #264 (closed) in !525 (merged), which was a large rewrite of the objects that are used by Nautilus, and it came afterwards…