ctf-reader: Optimize calling sorting function for functions and variables.

Message ID 20240619153048.98785-1-claudiu.zissulescu-ianculescu@oracle.com
State New
Headers
Series ctf-reader: Optimize calling sorting function for functions and variables. |

Commit Message

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

Sorting the functions and variables is done twce. Once in the
process_ctf_archive() and the second one, in read_corpus().  However,
we need to call them only once when we do the canonicalization of all
types and functions.  Thus, move canonicalization of types in
read_corpus() and perfom only once sorting the functions and types.

	* abg-ctf-reader.cc (process_ctf_archive()): Move
	canonicalize_all_types(), sort_functions() and sort_variables()...
	(read_corpus()): ...here, just after calling process_ctf_archive().

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

Comments

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

Sorry for my late reply, I was on the road the previous two weeks or so.

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

> From: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
>
> Sorting the functions and variables is done twce. Once in the
> process_ctf_archive() and the second one, in read_corpus().  However,
> we need to call them only once when we do the canonicalization of all
> types and functions.  Thus, move canonicalization of types in
> read_corpus() and perfom only once sorting the functions and types.
>
> 	* abg-ctf-reader.cc (process_ctf_archive()): Move
> 	canonicalize_all_types(), sort_functions() and sort_variables()...
> 	(read_corpus()): ...here, just after calling process_ctf_archive().
>
> Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>

The patch looks good to me.  I am running it through the CI builders on
sourceware.  You (and I) should receive an email in a while with the
result of the run.  I'll apply the patch then, if the result of run is
OK.  The branch which is being built is
https://sourceware.org/git/?p=libabigail.git;a=shortlog;h=refs/heads/users/dodji/try-patches.

Thanks!

[...]

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

[...]

>> From: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
>>
>> Sorting the functions and variables is done twce. Once in the
>> process_ctf_archive() and the second one, in read_corpus().  However,
>> we need to call them only once when we do the canonicalization of all
>> types and functions.  Thus, move canonicalization of types in
>> read_corpus() and perfom only once sorting the functions and types.
>>
>> 	* abg-ctf-reader.cc (process_ctf_archive()): Move
>> 	canonicalize_all_types(), sort_functions() and sort_variables()...
>> 	(read_corpus()): ...here, just after calling process_ctf_archive().
>>
>> Signed-off-by: Claudiu Zissulescu <claudiu.zissulescu-ianculescu@oracle.com>
>
> The patch looks good to me.  I am running it through the CI builders on
> sourceware.

[...]

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 f4fb91ed..86c7752e 100644
--- a/src/abg-ctf-reader.cc
+++ b/src/abg-ctf-reader.cc
@@ -511,13 +511,6 @@  public:
       }
 
     ctf_dict_close(ctf_dict);
-    /* Canonicalize all the types generated above.  This must be
-       done "a posteriori" because the processing of types may
-       require other related types to not be already
-       canonicalized.  */
-    canonicalize_all_types();
-    corpus()->sort_functions();
-    corpus()->sort_variables();
   }
 
   /// Add a new type declaration to the given libabigail IR corpus CORP.
@@ -702,6 +695,11 @@  public:
     else
       {
 	process_ctf_archive();
+	/* Canonicalize all the types generated above.  This must be
+	   done "a posteriori" because the processing of types may
+	   require other related types to not be already
+	   canonicalized.  */
+	canonicalize_all_types();
 	corpus()->sort_functions();
 	corpus()->sort_variables();
       }