-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autocomplete slower earlier queries redraw over newer ones #766
Comments
I wonder if a better approach might be to query for DISTINCT names once on initial page load via ajax and only update it if a name is submitted for a cluster that doesn't already exist in the browser-side cache. That would be a cheaper database query and a lot less queries in general during the whole cluster naming process. For comparison Then filter the names in browser with javascript on key up instead of server side queries. |
This has been a really annoying issue lately. I've looked through the code and it isn't going to be as easy as I thought it might be in when I made my last comment. It looks like the vendor autocomplete library supports caching natively, so I thought that enabling that in the vendor library calls might improve the experience all around: https://github.com/realsuayip/autocomplete However, enabling that cache doesn't appear to cause any less API calls as far as I can tell. I also tried a few things to optimize the lookup query (using outer join on images, etc.) but it didn't produce any meaningful improvement, if any at all. 🫤 EDIT: This looks like a bug upstream as the CachedResults is never actually populated. |
It looks like the reason that turning on caching didn't help is that when you're naming clusters, the Autocomplete() object gets reinstantiated in between each naming, so enabling cache does work in the library, but the cache is lost in between presenting new clusters to name. I also spent some time with doing some database query analytics yesterday (EXPLAIN, etc.) to see if I can make things more efficient at the database level, such as adding an index on name,user in the person table and tweaking the query, but again - nothing that made a notable improvement. If there was a way to persist the Autocomplete between cluster namings in assignName and turning cache, that would go a long way in improving things, but I'm not sure how to do this the way that it currently works since the input object is destroyed. Otherwise, turning cache on was a simple matter of adding |
I got it to work much better on the browser side by evaluating a request counter with a little bit of javascript. While I'm hopeful that the upstream library might get some improvements, I have a working POC locally to make this perform better in the meantime. I'll try to clean it up and get a PR to you for it. |
This is still an issue for the new release. I might make a video to show how cumbersome it is to try to do this without the patch. It's not just that the autocomplete isn't perfect, but it often ends up overwriting a selection with a different person unless you put a good 10 seconds or so between typing each individual letter. |
Expected behaviour
As you name someone and begin typing their name, the helpful auto-complete drop down box gives suggested names based on what is currently in the text box. If a more recent typing query has already been drawn for autocomplete, it should abandon the earlier query results.
Actual behaviour
With many people named, typing a name that begins with a letter in a lot of other names, the queries for the first letter (and subsequent shorter letters) might return after the queries against more letters in the name, redrawing the auto-complete box, even after a name has been selected, making naming more tedious and leading to occasional accidental wrong names.
Example from MariaDB slow log of queries for 'avo' returning before 'av' and before 'a':
![image](https://private-user-images.githubusercontent.com/5474941/352694347-adb95a76-2dd2-4af2-a7ee-9b47813617ec.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1MTk2NDAsIm5iZiI6MTczOTUxOTM0MCwicGF0aCI6Ii81NDc0OTQxLzM1MjY5NDM0Ny1hZGI5NWE3Ni0yZGQyLTRhZjItYTdlZS05YjQ3ODEzNjE3ZWMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTRUMDc0OTAwWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Nzc4YzgyZDk3YjczODRjYjM3MzY3OTRiZjE1MDdjOTJlOWMxYjU1OTk3ZDc2OWU3ZjYwOGJmYTk2NzkzMTU0ZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.I-AaUTBtcs9ahQ2L8Wm2wG0MJm_Z14LtxECpDskqf9s)
Steps to reproduce
Server configuration
Operating system:
Fedora 40
Pdlib version:
v1.1.0
How is DLib installed: Make sure it is working correctly with this tool
From Fedora repository
How is PDlib installed: Make sure it is working correctly with this tool
Compiled from git repo
PHP version:
8.3.9
Web server:
Apache httpd 2.4.62
Database:
mariadb-10.11.8
Nextcloud version:
29.0.4
Client configuration
Browser:
Firefox 127.0.2
Operating system:
Fedora 40
Logs
Background task log with debug.
sudo -u apache php occ -vvv face:background_job
Count of names for my Nextcloud user
Oddly enough, I haven't noticed this happening until recently - around the time I upgraded the database from MariaDB from 10.5 to 10.11. I turned on slow log and the slow log queries are exclusively coming from facerecognition.
The text was updated successfully, but these errors were encountered: