Skip to content

[v2] Second iteration of object layout changes#408

Merged
Anilm3 merged 29 commits into
anilm3/v2from
anilm3/object-refactor-second
Jun 6, 2025
Merged

[v2] Second iteration of object layout changes#408
Anilm3 merged 29 commits into
anilm3/v2from
anilm3/object-refactor-second

Conversation

@Anilm3

@Anilm3 Anilm3 commented May 28, 2025

Copy link
Copy Markdown
Collaborator

This PR completely changes ddwaf_object to be composed of multiple different subtypes, including small and literal (non-owned) strings. This new layout makes ddwaf_object a union in order to maximise the amount of memory that can be used within the small string, as well as to ensure that all fields are naturally aligned. The new string types:

  • Standard strings are limited to uint32_max characters, these don't have a capacity field so their capacity, i.e. the number of allocated bytes, must equal their size.
  • Small strings are an optimisation which uses the memory of the object itself to store strings up to 14 characters long.
  • Literal strings are also limited to uint32_max, but the main difference is that these aren't freed at all as they are intended to hold literals or non-owned strings.

In addition, this PR introduces an internal and external definition of ddwaf_object which is primarily to allow the use of internal types within the internal definition (detail::object), extending the type with convenience methods (although none have been added here), etc.

@codecov-commenter

codecov-commenter commented May 28, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 83.04094% with 29 lines in your changes missing coverage. Please review.

Project coverage is 85.39%. Comparing base (ccf13ac) to head (e9fdd3c).
Report is 3 commits behind head on anilm3/v2.

Files with missing lines Patch % Lines
src/object.hpp 77.31% 3 Missing and 24 partials ⚠️
src/interface.cpp 95.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           anilm3/v2     #408      +/-   ##
=============================================
- Coverage      85.44%   85.39%   -0.06%     
=============================================
  Files            176      176              
  Lines           8982     9015      +33     
  Branches        3828     3842      +14     
=============================================
+ Hits            7675     7698      +23     
- Misses           509      512       +3     
- Partials         798      805       +7     
Flag Coverage Δ
waf_test 85.39% <83.04%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pr-commenter

pr-commenter Bot commented May 28, 2025

Copy link
Copy Markdown

Benchmarks clang

Benchmark execution time: 2025-06-06 13:43:56

Comparing candidate commit e9fdd3c in PR branch anilm3/object-refactor-second with baseline commit ccf13ac in branch anilm3/v2.

Found 1 performance improvements and 0 performance regressions! Performance is the same for 0 metrics, 0 unstable metrics.

scenario:global-benchmark.random.clang

  • 🟩 execution_time [-8.104ms; -8.059ms] or [-3.018%; -3.002%]

@pr-commenter

pr-commenter Bot commented May 28, 2025

Copy link
Copy Markdown

Benchmarks gcc

Benchmark execution time: 2025-06-04 21:33:22

Comparing candidate commit e40a954 in PR branch anilm3/object-refactor-second with baseline commit ccf13ac in branch anilm3/v2.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

@pr-commenter

pr-commenter Bot commented May 28, 2025

Copy link
Copy Markdown

Benchmarks clang-pgo

Benchmark execution time: 2025-06-04 21:47:41

Comparing candidate commit e40a954 in PR branch anilm3/object-refactor-second with baseline commit ccf13ac in branch anilm3/v2.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics.

@Anilm3
Anilm3 marked this pull request as ready for review June 1, 2025 20:05
@Anilm3
Anilm3 requested a review from a team as a code owner June 1, 2025 20:05
Comment thread src/object_type.hpp Outdated
Comment thread src/object.hpp
Comment thread src/object.hpp
Comment thread src/object.hpp Outdated
Comment thread src/object.hpp Outdated
Comment thread src/object.hpp Outdated
@Anilm3
Anilm3 enabled auto-merge (squash) June 6, 2025 13:24
@Anilm3
Anilm3 merged commit a2469a3 into anilm3/v2 Jun 6, 2025
@Anilm3
Anilm3 deleted the anilm3/object-refactor-second branch June 6, 2025 13:49
Anilm3 added a commit that referenced this pull request Oct 1, 2025
* Object view: read only abstraction to ddwaf_object (#341)
* [v2] Remove mingw builds (#381)
* Writable objects: owned and borrowed object and object limits removal (#378, #382)
* [v2] Refactor and improve object types (#387)
* [v2] Update unit tests to use new abstractions (#389)
* [v2] Update `raw_configuration` type to use `object_view` (#390)
* [v2] Remove remaining uses of ddwaf_object in `src` and `tests/unit` (#391)
* [v2] JWT Decoding Processor (#401)
* [v2] First iteration of object layout changes (#394)
* Split context data insertion from evaluation (#407)
* [v2] Second iteration of object layout changes (#408)
* [v2] Add new fingerprint and object view tests (#414)
* Reenable attribute collector unit test (#415)
* [v2] Container view types (#413)
* Exclude assertions from coverage (#416)
* [v2] Use allocators internally instead of malloc/free and stop generating zero-terminated strings (#418)
* Add memory resource to owned and borrowed objects (#428)
* [v2] Propagate allocators from context (#420)
* [v2] Update interface and expose allocators (#427)
* Refactor evaluation stages out of the context (#442)
* Subcontext: replace ephemerals with a new scope with user-defined lifetime derived from the context (#443)
* Validator: Add support for testing subcontexts and attributes (#451)
* [v2] Pass allocator to context and subcontext eval and add new allocators (#452)
* Update logger to avoid dependencies on ddwaf.h (#453)
* [v2] Return DDWAF_MATCH when there are events, attributes or actions (#455)
* [v2] Cleanup: remove exclusion namespace and some redundant references (#456)
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.

3 participants