restart-server: Optimize prepopulating user cache.

We don't need to include long-term idle or other inactive users here,
since fetching them consumed to vast majority of the time.

(On chat.zulip.org, this decreased the runtime for populating the user
cache by 5x, removing only users we're unlikely to need to access).
This commit is contained in:
Tim Abbott 2018-08-01 12:51:08 -07:00
parent f10e006135
commit c42302e47b
1 changed files with 2 additions and 1 deletions

View File

@ -77,7 +77,8 @@ def session_cache_items(items_for_remote_cache: Dict[str, str],
# wrapper the below adds an extra 3ms or so to startup time for # wrapper the below adds an extra 3ms or so to startup time for
# anything importing this file). # anything importing this file).
cache_fillers = { cache_fillers = {
'user': (lambda: UserProfile.objects.select_related().all(), user_cache_items, 3600*24*7, 10000), 'user': (lambda: UserProfile.objects.select_related().filter(
long_term_idle=False), user_cache_items, 3600*24*7, 10000),
'client': (lambda: Client.objects.select_related().all(), client_cache_items, 3600*24*7, 10000), 'client': (lambda: Client.objects.select_related().all(), client_cache_items, 3600*24*7, 10000),
'recipient': (lambda: Recipient.objects.select_related().all(), recipient_cache_items, 3600*24*7, 10000), 'recipient': (lambda: Recipient.objects.select_related().all(), recipient_cache_items, 3600*24*7, 10000),
'stream': (lambda: Stream.objects.select_related().all(), stream_cache_items, 3600*24*7, 10000), 'stream': (lambda: Stream.objects.select_related().all(), stream_cache_items, 3600*24*7, 10000),