From 084b5c918c53c4e2eeb51664f3d403095f59f25d Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 21 Jan 2026 14:52:28 +0100 Subject: pkg/codesearch: reduce memory consumption when building index With all references in the index, it become quite big. Merge and dedup the resulting index on the fly. Also intern all strings b/c there are tons of duplicates. This also removes unnecessary duplicates (effectively ODR violations in the kernel) due to use of BUILD_BUG_ON. The macro produces different function calls in different translations units, so the same function may contain __compiletime_assert_N1 call in one TU and __compiletime_assert_N2 in another. Over this reduces resource consumption of index building from: time:296.11s user:16993.71s sys:6661.03s memory:82707MB to: time:194.28s user:16860.01s sys:6647.01s memory: 3243MB 25x reduction in memory consumption. --- pkg/declextract/entity.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkg/declextract') diff --git a/pkg/declextract/entity.go b/pkg/declextract/entity.go index 3b5e13a6d..82bf00446 100644 --- a/pkg/declextract/entity.go +++ b/pkg/declextract/entity.go @@ -228,7 +228,7 @@ type EntityGlobalAddr struct { Name string } -func (out *Output) Merge(other *Output) { +func (out *Output) Merge(other *Output, v *clangtool.Verifier) { out.Functions = append(out.Functions, other.Functions...) out.Consts = append(out.Consts, other.Consts...) out.Enums = append(out.Enums, other.Enums...) -- cgit mrf-deployment