From e21202022555f76207d28a7d04ccdc13f61b8239 Mon Sep 17 00:00:00 2001 From: WarGloom <539277+WarGloom@users.noreply.github.com> Date: Fri, 31 Jul 2026 01:34:55 +0000 Subject: [PATCH] Refactor string concatenation in calltree_analysis.py --- .jules/bolt.md | 3 +++ .../analyses/calltree_analysis.py | 20 ++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 .jules/bolt.md diff --git a/.jules/bolt.md b/.jules/bolt.md new file mode 100644 index 000000000..2b63dd231 --- /dev/null +++ b/.jules/bolt.md @@ -0,0 +1,3 @@ +## 2024-05-18 - [Optimizing HTML Generation Memory Overhead] +**Learning:** Found O(N^2) string concatenation using `+=` inside large loops in `src/fuzz_introspector/analyses/calltree_analysis.py` causing significant memory reallocation overhead when generating long calltree HTML pages. +**Action:** Replaced string accumulation with `list.append()` followed by `"".join(list)`. Next time, pre-emptively search for large scale string concatenations in HTML generating functions. diff --git a/src/fuzz_introspector/analyses/calltree_analysis.py b/src/fuzz_introspector/analyses/calltree_analysis.py index 3f01ca087..cd14e1655 100644 --- a/src/fuzz_introspector/analyses/calltree_analysis.py +++ b/src/fuzz_introspector/analyses/calltree_analysis.py @@ -295,14 +295,15 @@ def html_create_dedicated_calltree_file( the line it makes sense to have an easy wrapper for other HTML pages too. """ - complete_html_string = "" + # Performance Optimization: Replaced O(N^2) string concatenation with O(N) list joins. + complete_html_parts = [] blocker_infos = {} # HTML start html_header = html_helpers.html_get_header( title=f"Fuzz introspector: {profile.identifier}") html_header += "