Skip to content

Expression Parser Rewrite - #1144

Open
RuffledPlume wants to merge 1 commit into
117HD:masterfrom
RuffledPlume:ExpressionParserAllocations
Open

Expression Parser Rewrite#1144
RuffledPlume wants to merge 1 commit into
117HD:masterfrom
RuffledPlume:ExpressionParserAllocations

Conversation

@RuffledPlume

@RuffledPlume RuffledPlume commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Aims of this rewrite is to eliminate all garbage generation caused by testing the predicate generated by the ExpressionParser, to achieve this tried to remove all Lambdas from within the ExpressionParser, leaving only the VariableSupplier as the last potential lambda.

All Operator Lambdas have been replaced with explicit objects which achieve the same, this reduces scope capture ambiguity and instead its now clear where allocations are occurring and should now be a upfront cost to parsing instead of when testing.

VariableSupplier now supports:

  • getFloat
  • getInt
  • getBoolean
    and the original get which will cause boxing and ideally should be removed, its only being left for backwards compatibility.

Profile Capture Before:
image

After:
image

A Garbage reduction of 24 GB down to 27 MB over a 30 second profile capture (On master its view dependent, more dynamic models with color overrides will allocate significantly more, these captures we're taking in port sarim)

NOTE

Currently a draft since it needs allot of validating to ensure it matches up with the previous version, ideally we'd dump allot of data to test & verify

@RuffledPlume
RuffledPlume marked this pull request as draft July 20, 2026 04:30
@RuffledPlume
RuffledPlume force-pushed the ExpressionParserAllocations branch 4 times, most recently from 06cec6f to 9397034 Compare July 21, 2026 23:24
@RuffledPlume
RuffledPlume marked this pull request as ready for review July 22, 2026 20:35
@RuffledPlume

Copy link
Copy Markdown
Contributor Author

No longer draft since it passed a test pitting the new expression parser vs the old: RuffledPlume@765c490

22:39:14.552 [Client    ] DEBUG r.h.s.ModelOverrideManager     - Loaded 26086 model overrides
22:39:14.734 [Client    ] DEBUG r.h.s.ModelOverrideManager     - New Expression Parser Passed: 3837574 out of: 3837574

@RuffledPlume
RuffledPlume force-pushed the ExpressionParserAllocations branch from 939f16a to 0b77da1 Compare July 23, 2026 19:44
Sync

TODO: A good Commit Message :) I'm tired haha
Combine Individual Operations in batch operations

Fixes to test cases since now we support int types

Fix compileBoolean issues

Update TileOverrideVariables to implement `getInt` to avoid boxing

Optimise combined predicates by building a list instead of recursion

Sort conditions based on complexity

Static Imports

Added ShortCircuit path for BooleanComparisons

Minor Improvements

Optimise TileOverrideVariables

Move AHSLSupplier into its own class
@RuffledPlume
RuffledPlume force-pushed the ExpressionParserAllocations branch from 0b77da1 to 7d30280 Compare July 27, 2026 01:08
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