Skip to content

Fix double-counting of Automaton in AutomatonQuery#ramBytesUsed - #16390

Merged
mikemccand merged 1 commit into
apache:mainfrom
Sasilekha:fix/16389-automaton-query-rambytes-double-count
Jul 14, 2026
Merged

Fix double-counting of Automaton in AutomatonQuery#ramBytesUsed#16390
mikemccand merged 1 commit into
apache:mainfrom
Sasilekha:fix/16389-automaton-query-rambytes-double-count

Conversation

@Sasilekha

@Sasilekha Sasilekha commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Addresses #16389.
AutomatonQuery#ramBytesUsed() double-counts the underlying Automaton when isBinary=true CompiledAutomaton already accounts for it via runAutomaton/nfaRunAutomaton, but the outer query added automaton.ramBytesUsed() on top.

Fix adds CompiledAutomaton#sharesAutomaton(Automaton) to detect when the same instance is held internally, and skips the outer contribution in that case.

@Sasilekha
Sasilekha force-pushed the fix/16389-automaton-query-rambytes-double-count branch 3 times, most recently from 5a463ac to 002e141 Compare July 14, 2026 09:30
@Sasilekha
Sasilekha force-pushed the fix/16389-automaton-query-rambytes-double-count branch from 002e141 to 58727c0 Compare July 14, 2026 09:39
@Sasilekha
Sasilekha marked this pull request as ready for review July 14, 2026 12:12

@mikemccand mikemccand left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, and nice catch -- thanks @Sasilekha . I'll merge and backport.

@mikemccand
mikemccand merged commit d7d1240 into apache:main Jul 14, 2026
12 checks passed
@mikemccand

Copy link
Copy Markdown
Member

Thanks @Sasilekha -- I also backported to 10.6.0, and moved the CHANGES.txt entry down. I had to remove NFA mention in the javadoc, one line code, and whole test case -- please have a peek to see if it's right? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants