Skip to content

fix(data): replace Formatter-based hex conversion that OOM-crashed (COLUMBA-EE) - #1208

Merged
torlando-tech merged 1 commit into
mainfrom
fix/columba-ee-hex-oom
Oct 22, 2026
Merged

torlando-tech merged 1 commit into
mainfrom
fix/columba-ee-hex-oom

Conversation

@torlando-tech

@torlando-tech torlando-tech commented Oct 22, 2026 •

Copy link
Copy Markdown
Owner

Observed failure

Sentry COLUMBA-EE reports a fatal 24-byte allocation failure while saving an announce. ART reported a 256 MiB heap limit and less than 1% free after GC. The failure occurred in per-byte String.format during hex encoding of 16 SHA-256 digest bytes. The event does not identify what occupied the heap.

Allocation mitigation

  • Replace Formatter-based ByteArray and List hex conversion with a CharArray and hex-digit lookup.
  • Replace hash.take(16) with hash.copyOf(16) to avoid the intermediate list.

This reduces temporary allocation. It does not establish or fix the source of COLUMBA-EE's heap exhaustion.

Verification and limits

Allocation-budget tests use 64 KiB inputs, producing 128 KiB hex output. The previous implementation allocated 36.6/37.9 MB per conversion against a 1 MiB budget; the optimized implementation passed that budget. These inputs are substantially larger than the 16-byte identity-hash conversion in the event. The tests reproduce allocation inefficiency, NOT the production OOM.

The prior run reported passing HashUtils tests, the full data unit-test suite, and data ktlint. No Android heap-occupancy reproduction was performed. COLUMBA-EE's underlying cause remains unverified.

…OLUMBA-EE)

"%02x".format(it) builds a java.util.Formatter per byte; measured ~37 MB
of garbage for a 128 KiB hex string. On a heap already below 1% free
after GC, the next 24-byte allocation in this path threw OOM and killed
the process (Sentry COLUMBA-EE, AnnounceRepository.saveAnnounce hot
path). Switch to a CharArray + hex-digit lookup (~3x output size) and
drop the boxed take(16) list in computeIdentityHash.

Regression tests bound toHexString allocation to <8x output via
ThreadMXBean.getThreadAllocatedBytes: ~37 MB allocated before, ~0.4 MB
after, budget 1 MiB.

Fixes COLUMBA-EE
@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Summary

Replaces per-byte Formatter calls with a lookup table and a character array in both toHexString overloads.

  • HashUtils builds lowercase hex text with far less temporary allocation.

Reviews (1) · Last reviewed commit: "fix(data): replace Formatter-based hex c..." · Reviewed by Greptile

@codecov

codecov Bot commented Oct 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@torlando-tech
torlando-tech merged commit 7299680 into main Oct 22, 2026
15 checks passed
@torlando-tech
torlando-tech deleted the fix/columba-ee-hex-oom branch October 22, 2026 14:56
@torlando-tech

Copy link
Copy Markdown
Owner Author

Diagnosis correction: the allocation-budget test reproduced excessive temporary allocation on 64 KiB inputs, not COLUMBA-EE. The crashing identity-hash conversion formats only 16 bytes. The event does not establish what occupied the 256 MiB heap. The optimization remains useful, but should be treated as an allocation mitigation, not a verified root-cause fix. PR description corrected accordingly; no merged history rewritten.

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.

1 participant