[PATCH] debuginfo fdcache prefetching tweak

Frank Ch. Eigler fche@redhat.com
Wed Oct 21 00:45:43 GMT 2020


Subject: [PATCH 2/2] debuginfod: suppress fdcache prefetching during dwz
 lookup

From: Frank Ch. Eigler <fche@redhat.com>

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      |  5 +++++
 debuginfod/debuginfod.cxx | 20 +++++++++++++-------
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
index 236e2ca3270f..fd67cc8bcccd 100644
--- a/debuginfod/ChangeLog
+++ b/debuginfod/ChangeLog
@@ -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-10-20  Frank Ch. Eigler  <fche@redhat.com>
 
 	PR26756: more prometheus metrics
diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
index a5334d2a7fc5..7f9fde171777 100644
--- a/debuginfod/debuginfod.cxx
+++ b/debuginfod/debuginfod.cxx
@@ -898,10 +898,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)
     {
@@ -1254,7 +1256,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)
@@ -1358,7 +1361,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
     {
@@ -1452,16 +1456,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;
 }
@@ -1559,7 +1564,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;
     }
-- 
2.26.2



More information about the Elfutils-devel mailing list