Skip to content

[AUTOMATED] fix(analysis): reduce AIF gap scan memory and repeated validation - #799

Merged
mahaloz merged 2 commits into
Noelo-Lab:mainfrom
phix33:fix/aif-gap-performance
Oct 1, 2026
Merged

mahaloz merged 2 commits into
Noelo-Lab:mainfrom
phix33:fix/aif-gap-performance

Conversation

@phix33

@phix33 phix33 commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

The problem

Selecting one tiny ARM function with aggressive analysis can retain about 1 GiB
and spend most of its time scanning gaps. With built kuna/specs, Python 3 and GNU
ARM binutils, this authored input reproduces it on the unpatched tree:

mkdir -p ../tmp/aif-repro
python3 - <<'PY' | arm-linux-gnueabi-as -march=armv7-a -o ../tmp/aif-repro/gap.o
print('.text\n.arm')
for i in range(4096):
    print(f'.global f{i}\n.type f{i}, %function\nf{i}:\nmov r0, #7\nbx lr\n'
          f'.size f{i}, .-f{i}\n.word 0xe320f000, 0xe320f000')
print('.fill (16777216-4096*16)/4, 4, 0xe320f000')
PY
arm-linux-gnueabi-ld -Ttext=0x80000000 -e f0 -o ../tmp/aif-repro/gap.elf ../tmp/aif-repro/gap.o
for listing in on off; do
  /usr/bin/time -f 'elapsed=%e maxrss=%M KiB' decompiler/target/release/kuna \
    decompile ../tmp/aif-repro/gap.elf f0 --mode aggressive \
    --option fast_funcdisc off --option listing "$listing" >/dev/null
done
elapsed=13.34 maxrss=1031096 KiB
elapsed=3.29 maxrss=131936 KiB

The same run after the change takes 6.39 s / 138060 KiB with Listing on; both
versions still emit return 7;. These are single-run observations on this host.

The fix

  • Retire consumed probes while preserving the first decode of forward addresses.
  • Reuse overlapping validation, preserving discovery thresholds and the
    4,000-instruction limit.
  • Share decode data and avoid duplicate parsing; retain separate assembly parsing
    for instructions with context commits or delay slots.

Memory use still depends on forward probes retained for later candidates, so the
measured reduction does not establish a universal memory cap. Remaining Listing
and operand-reference costs are outside this change.

The tests

The padding-retention regression fails before this change. Discovery-order,
branch/context and paired-decoding tests pass, as do both parity suites without
changed expectations. The cargo workspace suite passes.

phix33 and others added 2 commits October 1, 2026 17:29
[AUTOMATED] Retire consumed gap probes, reuse overlapping validation prefixes, and avoid duplicate SLEIGH parsing while preserving discovery order and first forward decodes. Add authored regression cases and combined-decode equivalence coverage.
@mahaloz

mahaloz commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

[AUTOMATED] Merged current main into this branch (it merged cleanly; your files are unchanged) and replaced the description's sentence about a workspace-suite failure, since the cargo workspace suite passes in CI on 1744689. Thanks for the change.

@mahaloz
mahaloz merged commit 5fd65b2 into Noelo-Lab:main Oct 1, 2026
2 checks passed
@phix33
phix33 deleted the fix/aif-gap-performance branch October 5, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants