Bug 45076 - UMC freezes when the search in package management module returns too many results
UMC freezes when the search in package management module returns too many res...
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: UMC - Package management
UCS 4.2
Other Linux
: P5 normal (vote)
: UCS 4.2-3-errata
Assigned To: Jürn Brodersen
Johannes Keiser
:
: 45624 (view as bug list)
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-07-26 15:16 CEST by Johannes Keiser
Modified: 2018-01-29 17:13 CET (History)
4 users (show)

See Also:
What kind of report is it?: Bug Report
What type of bug is this?: 4: Minor Usability: Impairs usability in secondary scenarios
Who will be affected by this bug?: 3: Will affect average number of installed domains
How will those affected feel about the bug?: 3: A User would likely not purchase the product
User Pain: 0.206
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): UCS Performance, Usability
Max CVSS v3 score:
best: Patch_Available+


Attachments
proposed patch (1.20 KB, patch)
2017-07-26 18:30 CEST, Jürn Brodersen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Keiser univentionstaff 2017-07-26 15:16:47 CEST
I made a search for every package (with *) and the UMC froze.

There were 48736 packages in the search result and the UMC froze for approximately 1 minute. (chromium browser)

In Firefox I at least got a message that a script is not responding.

The unresponsive script was this line from umc/widgets/Grid.js:
return a.localeCompare(b, kernel.locale, {numeric: true}) < 0;

// some context
var compare = function(aValue, bValue) {
	var a = sortFormatter(aValue);
	var b = sortFormatter(bValue);
	if (typeof(a.localeCompare) === 'function') {
		return a.localeCompare(b, kernel.locale, {numeric: true}) < 0;
	} else if (typeof(a.toLowerCase) === 'function') {
		return a.toLowerCase() < b.toLowerCase();
	} else {
		return a < b;
	}
};
Comment 1 Florian Best univentionstaff 2017-07-26 15:35:48 CEST
Could this be a regression by Bug #44431?
Comment 2 Jürn Brodersen univentionstaff 2017-07-26 16:23:56 CEST
(In reply to Florian Best from comment #1)
> Could this be a regression by Bug #44431?

It's bug 44361 :(

The localeCompare function I used is a lot slower than I expected...
I'm looking into alternatives. The easiest solution might be to check how many entries we need to sort and not using locale aware sorting for more than X entries.
Comment 3 Jürn Brodersen univentionstaff 2017-07-26 18:30:57 CEST
Created attachment 9065 [details]
proposed patch

The patch uses a pre initialized Intl.Collator object (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator) which speeds up the comparison significantly.

Times for sorting 48736 packages:
intlCollator.compare(a, b): 571ms
a.toLowerCase() < b.toLowerCase(): 231ms
a < b: 87ms

MDN suggests sorting with a map:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
But I think that would need quite a bit of time and effort to implement.
Comment 4 Florian Best univentionstaff 2017-11-01 13:44:17 CET
*** Bug 45624 has been marked as a duplicate of this bug. ***
Comment 5 Jürn Brodersen univentionstaff 2018-01-17 17:32:59 CET
4.2-3:
    b890537e
    47f2d0d7
    849c12c0
    90b67e51
    7d65e151: YAML

4.3-0:
    89d875ef
    9350e992
    1d5a065f
    1e8826bd
Comment 6 Johannes Keiser univentionstaff 2018-01-24 13:06:40 CET
OK Code
OK Sorting of 50.000 grid entries now takes < 1s
OK Sorting with undefined/null values inbetween still works
~OK Sorting a column where every value is the same (e.g. path in users) sorts arbitrarily. see Bug #44690
OK Merge
OK YAML (bd61598)
-> verified
Comment 7 Arvid Requate univentionstaff 2018-01-29 17:13:58 CET
<http://errata.software-univention.de/ucs/4.2/271.html>