From 347039f64509e77ad5f6ef52ae70950c91886f8e Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Thu, 13 Feb 2025 18:56:46 +0100 Subject: src: add symbol range expression to further compact intervals Update parser to use a new symbol range expression with smaller memory footprint than range expression + two symbol expressions. The evaluation step translates this into EXPR_RANGE_VALUE for interval sets. Note that maps or concatenations still use the less compact range expressions representation, those require more work to use this new symbol range expression. The parser also uses the classic range expression if variables are used. Testing with a 100k intervals, worst case scenario: no prefix or singleton elements. This shows a reduction from 49.58 Mbytes to 35.47 Mbytes (-29.56% memory footprint for this case). This follow up work to previous commits: 91dc281a82ea ("src: rework singleton interval transformation to reduce memory consumption") c9ee9032b0ee ("src: add EXPR_RANGE_VALUE expression and use it") Signed-off-by: Pablo Neira Ayuso --- src/optimize.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/optimize.c') diff --git a/src/optimize.c b/src/optimize.c index 03c8bad2..230fe4a2 100644 --- a/src/optimize.c +++ b/src/optimize.c @@ -139,6 +139,7 @@ static bool stmt_expr_supported(const struct expr *expr) { switch (expr->right->etype) { case EXPR_SYMBOL: + case EXPR_RANGE_SYMBOL: case EXPR_RANGE: case EXPR_PREFIX: case EXPR_SET: @@ -630,6 +631,7 @@ static void __merge_concat(const struct optimize_ctx *ctx, uint32_t i, case EXPR_SYMBOL: case EXPR_VALUE: case EXPR_PREFIX: + case EXPR_RANGE_SYMBOL: case EXPR_RANGE: clone = expr_clone(stmt_a->expr->right); compound_expr_add(concat, clone); @@ -730,6 +732,7 @@ static void build_verdict_map(struct expr *expr, struct stmt *verdict, stmt_free(counter); break; case EXPR_PREFIX: + case EXPR_RANGE_SYMBOL: case EXPR_RANGE: case EXPR_VALUE: case EXPR_SYMBOL: -- cgit v1.2.3