[PATCH 14/14] ir: Speed-up type canonicalization by NOT clearing up caches too often
Dodji Seketeli
dodji@seketeli.org
Fri Sep 25 21:06:08 GMT 2026
During the parallel type canonicalization (aka c14n) performed by
c14n_task::perform, the thread-local type comparison cache is cleared
up after each type c14n. When canonicalizing more than 2 millions
types, like for the vmlinux binary, it turns out this can make the
whole type c14n process take a lot of time (several hours). This
patch keeps the cache live for the duration of the c14n of all the
types of a given homonym type group, in a given thread. The cache is
cleared only at the end of the c14n of all the types of the group.
This reduces the time back to a few minutes for c14n of the types of
the second binary that is loaded.
Please note that we still need to clear the cache to avoid spurious
comparison results later when doing compute_diff post c14n. This is
because there might still be some missing look_through_decl_only here
and there (probably in the hashing code or in the comparison code)
that induce some spurious changes that can be intermittent.
With this patch and all the previous ones here are some performance
data when comparing the vmlinux binary to itself on a laptop from
2022:
$ /usr/bin/time ~/git/libabigail/libabigail-2.10-branch/build/tools/abidiff --verbose build/vmlinux build/vmlinux
5199.55user 5.54system 1:27:14elapsed 99%CPU (0avgtext+0avgdata 7832708maxresident)k
47560inputs+0outputs (25major+2197876minor)pagefaults 0swaps
$ /usr/bin/time ~/git/libabigail/multithreading/build/tools/abidiff build/vmlinux build/vmlinux
5398.14user 1074.56system 10:11.11elapsed 1059%CPU (0avgtext+0avgdata 38357500maxresident)k
0inputs+0outputs (0major+10082711minor)pagefaults 0swaps
That is almost a 8x speedup \o/
The problem is that it now takes 38GB of ram instead of 7GB to
process. That's more than a 5x increase in memory consumption. I
guess that is related to the fact that since type DIEs are not
de-duplicated anymore, since the multithreading work, we are seeing
more than 2 million types to canonicalize. That results in 30557
canonical types. When we were still de-duplicated type DIEs at the
DWARF level, we were seeing less than 1 million types.
* src/abg-ir-priv.h (c14n_task::perform): Clear the type
comparison result cache only after canonicalizing all the types of
the homonym type group.
Signed-off-by: Dodji Seketeli <dodji@seketeli.org>
---
src/abg-ir-priv.h | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/abg-ir-priv.h b/src/abg-ir-priv.h
index 0196f08c..6b6b37b2 100644
--- a/src/abg-ir-priv.h
+++ b/src/abg-ir-priv.h
@@ -1926,11 +1926,12 @@ struct c14n_task : public abigail::workers::task
}
environment::priv::allow_type_comparison_results_caching(true);
+
for (auto type : group->get_types())
- {
- canonicalize(type, group, do_log, do_show_stats);
- environment::priv::clear_type_comparison_results_cache();
- }
+ canonicalize(type, group, do_log, do_show_stats);
+
+ environment::priv::clear_type_comparison_results_cache();
+
environment::priv::allow_type_comparison_results_caching(false);
if (do_log)
--
2.55.0
More information about the Libabigail
mailing list