Skip to content

Fix optimize lists command

Created by: salaun-urennes1

Two commits in this branch, the second one depending on the first:

  1. Fix List.pm cache management. _cache_put() did not set '_mtime' ; it prevented the cache from being used by _cache_get(). PR #583 introduced a bug: most of the time equals ; _cache_get() returned undef whereas the data was in cache.
  2. Optimize the do_lists() function. Profiling analysis reveals that the cost of this subroutine is related to SQL queries for each list in admin_table and subscriber_table. The trick here is to do a single SQL query to initialize List.pm's cache. Subsequent is-subscriber() or is_owner() checks are performed with no additionnal SQL queries.

I think (1) shoud really be applied upstream. For (2), it's up to you since I didn't observe significant response time progress on our staging server with 2.400 mailing lists. Given our discussion in #584, I know that you want to remove caching in Sympa, so you might not like to add more of it.

For the records, here are the profiling results before and after these changes. You'll notice that do_prepared_query() is much less called afterward:

Profiling before the code changes: profiler-global-branch-6 2-asis profiler-sql-queries-branch-6 2-asis

Profiling after the code changes: profiler-global-branch-6 2-limit-sql-queries profiler-sql-queries-branch-6 2-limit-sql-queries

Merge request reports