Bug 58278 - Performance enhancement for UDM REST API object lookup
Summary: Performance enhancement for UDM REST API object lookup
Status: CLOSED FIXED
Alias: None
Product: UCS
Classification: Unclassified
Component: UDM - REST API
Version: UCS 5.2
Hardware: Other Linux
: P5 normal
Target Milestone: UCS 5.2-1-errata
Assignee: Florian Best
QA Contact: Felix Botner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-05-16 11:50 CEST by Florian Best
Modified: 2025-05-28 13:40 CEST (History)
1 user (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): UCS Performance
Customer ID:
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Florian Best univentionstaff 2025-05-16 11:50:18 CEST
The get_properties() method uses a recursive function, which depending on the recursion size costs performance by a growing stack.

This can be replaced with a simple loop and a queue.
A benchmark showed:

> Recursive version total time: 0.103486 seconds
> Iterative version total time: 0.084145 seconds
> Recursive avg time per call: 0.000103486 seconds (103.486 microseconds)
> Iterative avg time per call: 0.000084145 seconds (84.145 microseconds)
> Iterative version is FASTER by 0.019341 seconds (18.69%).
> Iterative version is approx 1.23 times faster.
Comment 2 Florian Best univentionstaff 2025-05-16 13:49:37 CEST
I tested it also for a regular domain user, a few requests and picked the best one:

Before: Best of 10-20 requests:
# time curl -s -H 'Accept: application/json' 'http://Administrator:univention@localhost/univention/udm/users/user/uid=foo,'$(ucr get ldap/base) > /dev/null 

real    0m0,096s
user    0m0,063s
sys     0m0,019s

After: Best of 10-20 requests:
# time curl -s -H 'Accept: application/json' 'http://Administrator:univention@localhost/univention/udm/users/user/uid=foo,'$(ucr get ldap/base) > /dev/null 

real    0m0,082s
user    0m0,062s
sys     0m0,012s

improve: 13 %
Comment 3 Florian Best univentionstaff 2025-05-16 13:51:00 CEST
A stack based dequeue is now used.

univention-management-console-module-udm.yaml
5d0778eb69f3 | perf(udm-umc): speed up get_properties by removing recursion

univention-management-console-module-udm (12.0.10)
24d27046f533 | perf(udm-umc): fix manual-list-comprehension PERF401
5d0778eb69f3 | perf(udm-umc): speed up get_properties by removing recursion
Comment 4 Felix Botner univentionstaff 2025-05-27 12:57:41 CEST
OK - yaml
OK - get_properties() still works
OK - slightly faster
Comment 5 Christian Castens univentionstaff 2025-05-28 13:40:34 CEST
<https://errata.software-univention.de/#/?erratum=5.2x115>