Edgewall Software

Opened 6 years ago

Last modified 5 years ago

#11868 closed enhancement

Cache Environment.get_known_users — at Version 2

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.0.3
Component: general Version:
Severity: normal Keywords: environment
Cc: Steffen Hoffmann, trac@…, leho@… Branch:
Release Notes:

Environment.get_known_users() is cached.

API Changes:

Removed the overridden method get_known_users in EnvironmentStub that returned users from the attribute known_users.

Internal Changes:


The list of known users returned by Environment.get_known_users should be cached.

Change History (3)

comment:1 by Ryan J Ollos, 6 years ago

Cc: Steffen Hoffmann added

The get_known_users method added to EnvironmentStub in [2799] looks like an unnecessary override that makes it difficult to test the true behaviour of get_known_users. It's straightforward to modify the tests to make the override unnecessary.

Removing the override is an API change; if anyone has concerns about that I can probably find a way to keep some backwards compatibility. A search of t-h.o reveals only one use of EnvironmentStub.known_users: browser:/tracformsplugin/trunk/0.11/tracforms/formdb.py@11137:418#L414.

Last edited 6 years ago by Ryan J Ollos (previous) (diff)

comment:2 by Ryan J Ollos, 6 years ago

API Changes: modified (diff)
Release Notes: modified (diff)
Status: newassigned

Proposed changes in log:rjollos.git:t11868, based on the branch from #11867.

I considered fixing this on 1.0-stable. Let me know any thoughts on that. I get the following results with attachment:test_get_known_users.py:

Num Users Time w/o caching First retrieval with caching Retrieval from cache
1k 7 ms 12 ms < 1 ms
10k 70 ms 120 ms < 1 ms
100k 800 - 900 ms 1200 ms < 5 ms

Not surprisingly it scales linearly with number of users.

Last edited 6 years ago by Ryan J Ollos (previous) (diff)

by Ryan J Ollos, 6 years ago

Attachment: test_get_known_users.py added
Note: See TracTickets for help on using tickets.