ctf-reader: Add time logging to CTF reader

Message ID 20240619153159.98933-1-claudiu.zissulescu-ianculescu@oracle.com
State New
Headers
Series ctf-reader: Add time logging to CTF reader |

Commit Message

Claudiu Zissulescu-Ianculescu June 19, 2024, 3:31 p.m. UTC
  From: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>

Log the time spent while reading the CTF archive and canonicalizing it.

    * src/abg-ctf-reader.cc (do_log()): Getter of the do_log flag.
    (read_corpus()): Add time logging.

Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
---
 src/abg-ctf-reader.cc | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
  

Comments

Dodji Seketeli June 21, 2024, 11:47 a.m. UTC | #1
Hello Claudiu,

claudiu.zissulescu-ianculescu@oracle.com a écrit:

> From: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
>
> Log the time spent while reading the CTF archive and canonicalizing it.
>
>     * src/abg-ctf-reader.cc (do_log()): Getter of the do_log flag.
>     (read_corpus()): Add time logging.
>
> Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>

The obviously looks good to me.  I am testing it through the CI builders
on sourceware and you should receive an email with the result once the
run is over.  The exact content of the branch being tested is
https://sourceware.org/git/?p=libabigail.git;a=shortlog;h=refs/heads/users/dodji/try-patches.

I will apply the patch once the CI builders are over.

Many thanks!

[...]

Cheers,
  
Dodji Seketeli June 21, 2024, 12:33 p.m. UTC | #2
Dodji Seketeli <dodji@seketeli.org> a écrit:

[...]

>> From: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
>>
>> Log the time spent while reading the CTF archive and canonicalizing it.
>>
>>     * src/abg-ctf-reader.cc (do_log()): Getter of the do_log flag.
>>     (read_corpus()): Add time logging.
>>
>> Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>

[...]

> I will apply the patch once the CI builders are over.

... and the builders are green so I have applied the patch to the
mainline!  Thanks!

[...]

Cheers,
  

Patch

diff --git a/src/abg-ctf-reader.cc b/src/abg-ctf-reader.cc
index 623bfa2b..67db400e 100644
--- a/src/abg-ctf-reader.cc
+++ b/src/abg-ctf-reader.cc
@@ -42,6 +42,9 @@  ABG_END_EXPORT_DECLARATIONS
 
 namespace abigail
 {
+
+using std::cerr;
+
 /// Namespace of the reader for the CTF debug information
 namespace ctf
 {
@@ -327,6 +330,16 @@  public:
   env()
   {return options().env;}
 
+  /// Getter of the "do_log" flag.
+  ///
+  /// This flag tells if we should log about various internal
+  /// details.
+  ///
+  /// return the "do_log" flag.
+  bool
+  do_log() const
+  {return options().do_log;}
+
   /// Look for vmlinux.ctfa file in default directory or in
   /// directories provided by debug-info-dir command line option,
   /// it stores location path in @ref ctfa_file.
@@ -680,6 +693,10 @@  public:
           && (status & fe_iface::STATUS_DEBUG_INFO_NOT_FOUND))
       return corp;
 
+    tools_utils::timer t;
+    if (do_log())
+      t.start();
+
     int errp;
     if ((corp->get_origin() & corpus::LINUX_KERNEL_BINARY_ORIGIN)
 	&& corpus_group())
@@ -699,6 +716,13 @@  public:
       ctfa = ctf_arc_bufopen(&ctf_sect, &symtab_sect,
 			     &strtab_sect, &errp);
 
+    if (do_log())
+      {
+	t.stop();
+	cerr << "Reading CTF info in:" << t << "\n";
+	t.start();
+      }
+
     env().canonicalization_is_done(false);
     if (ctfa == NULL)
       status |= fe_iface::STATUS_DEBUG_INFO_NOT_FOUND;
@@ -716,6 +740,12 @@  public:
 
     env().canonicalization_is_done(true);
 
+    if (do_log())
+      {
+	t.stop();
+	cerr << "Building ABG-IR in:" << t << "\n";
+      }
+
     return corp;
   }