]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod: suppress fdcache prefetching during dwz lookup
authorFrank Ch. Eigler <fche@redhat.com>
Tue, 20 Oct 2020 23:26:04 +0000 (19:26 -0400)
committerFrank Ch. Eigler <fche@redhat.com>
Wed, 21 Oct 2020 14:06:51 +0000 (10:06 -0400)
During a recent from-scratch reindexing of the rpm/deb corpus at
debuginfod.elfutils.org, we found the fdcache chewed up an abnormal
amount of $TMPDIR space.  This was due to internal .dwz lookups, which
triggered fdcache prefetching as for a webapi query, but there was not
a timely fdcache eviction pass to clean it up again.  Rather than add
that pass, it's better to suppress the prefetching completely, as an
internal .dwz search will only ever need that file, not any others
from the same archive.

Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
debuginfod/ChangeLog
debuginfod/debuginfod.cxx

index 8cb89967e9d1bc68f1231d4f7c90572855ae660c..688404e5d56792a5f17c94009d28fa063b1d923a 100644 (file)
@@ -1,3 +1,8 @@
+2020-10-20  Frank Ch. Eigler  <fche@redhat.com>
+
+       * debuginfod.cxx (handle_buildid*): Add a parameter for detecting
+       internally-originated lookups for dwz resolution.
+
 2020-09-18  Frank Ch. Eigler <fche@redhat.com>
 
        * debuginfod.cxx (scan_source_file, archive_classify): Store only
index 140b7789de3ba0eaddc14a346eef9c030de35e7d..7907fecc7419f6c51a162992447ab12500beb0b6 100644 (file)
@@ -890,10 +890,12 @@ add_mhd_last_modified (struct MHD_Response *resp, time_t mtime)
 
 
 static struct MHD_Response*
-handle_buildid_f_match (int64_t b_mtime,
+handle_buildid_f_match (bool internal_req_t,
+                        int64_t b_mtime,
                         const string& b_source0,
                         int *result_fd)
 {
+  (void) internal_req_t; // ignored
   int fd = open(b_source0.c_str(), O_RDONLY);
   if (fd < 0)
     {
@@ -1226,7 +1228,8 @@ string canonicalized_archive_entry_pathname(struct archive_entry *e)
 
 
 static struct MHD_Response*
-handle_buildid_r_match (int64_t b_mtime,
+handle_buildid_r_match (bool internal_req_p,
+                        int64_t b_mtime,
                         const string& b_source0,
                         const string& b_source1,
                         int *result_fd)
@@ -1330,7 +1333,8 @@ handle_buildid_r_match (int64_t b_mtime,
   // 3) extract some number of prefetched entries (just into fdcache)
   // 4) abort any further processing
   struct MHD_Response* r = 0;                 // will set in stage 2
-  unsigned prefetch_count = fdcache_prefetch; // will decrement in stage 3
+  unsigned prefetch_count =
+    internal_req_p ? 0 : fdcache_prefetch;    // will decrement in stage 3
 
   while(r == 0 || prefetch_count > 0) // stage 1, 2, or 3
     {
@@ -1424,16 +1428,17 @@ handle_buildid_r_match (int64_t b_mtime,
 
 
 static struct MHD_Response*
-handle_buildid_match (int64_t b_mtime,
+handle_buildid_match (bool internal_req_p,
+                      int64_t b_mtime,
                       const string& b_stype,
                       const string& b_source0,
                       const string& b_source1,
                       int *result_fd)
 {
   if (b_stype == "F")
-    return handle_buildid_f_match(b_mtime, b_source0, result_fd);
+    return handle_buildid_f_match(internal_req_p, b_mtime, b_source0, result_fd);
   else if (b_stype == "R")
-    return handle_buildid_r_match(b_mtime, b_source0, b_source1, result_fd);
+    return handle_buildid_r_match(internal_req_p, b_mtime, b_source0, b_source1, result_fd);
   else
     return 0;
 }
@@ -1531,7 +1536,8 @@ handle_buildid (MHD_Connection* conn,
 
       // Try accessing the located match.
       // XXX: in case of multiple matches, attempt them in parallel?
-      auto r = handle_buildid_match (b_mtime, b_stype, b_source0, b_source1, result_fd);
+      auto r = handle_buildid_match (conn ? false : true,
+                                     b_mtime, b_stype, b_source0, b_source1, result_fd);
       if (r)
         return r;
     }