Repository navigation
Conversation
A view is a performance optimization for high-load environments where transforming key/value data is on the hot path. It gives the interface of a string-keyed map over data that stays where it already is: the bytes it arrived in, or a native cfl_kvlist. It keeps one entry per pair with a borrowed key and a backend handle, so lookups, renames, removals and inserts do not build a CFL object for every key and value. The interface covers typed append and replace, owned CFL objects, optional copying of the keys and values handed to edits, exact and case-insensitive lookup, materialization into a kvlist or an arena, and a kvlist backend that commits the edits back to the list. It is marked experimental: names, layouts and semantics can change. Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Exercise reads, typed edits, copy mode, owned objects, arena-backed lists, a backend over data that is not made of CFL objects, and table growth. Add the header to the self-contained header checks and use a view from the installed consumer fixture. Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Add VIEW.md with the model, the API, the ownership rules, and guides for writing a backend and an encoder. Reference it from the README, the changelog and the contributor guide. Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
Shellcheck reports SC1007 for 'CDPATH= cd', which fails the lint job on every pull request. Assign the empty string explicitly; the behavior is the same. Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
The clang-sanitize-memory job fails on every run since ubuntu-latest moved to Ubuntu 26.04: a different set of tests segfaults each time, including programs that only contain an empty main(). The Clang 11 sanitizer runtime in the analysis container reserves fixed address ranges, which the higher mmap randomization of the new runner kernel can overlap. Lower vm.mmap_rnd_bits on the runner before the analysis container starts. Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
edsiper
requested review from
niedbalski and
patrick-stephens
as code owners
November 26, 2026 21:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In high-load environments, transforming key/value data is on the hot path. Today every transformation has to build a
cfl_kvlistfor each map first: a heap pair, a key string and a variant per attribute, most of which are never read or changed. In Fluent Bit this is the largest remaining cost when a processor edits log attributes at a high rate.What this adds
cfl_view: a performance optimization for data transformation under high load. A view gives the interface of a string-keyed map over data that stays where it already is (the bytes it arrived in, another library's objects, or a nativecfl_kvlist), so pairs are looked up and edited without building a CFL object for each one.A view is a table with one entry per pair: a borrowed key and an opaque backend handle. Values are not decoded at load time. Lookups and edits run on that table, and the original data is never written, so it works as a copy-on-write overlay.
cfl_view_find(),cfl_view_find_ex()(case-insensitive, likecfl_kvlist_fetch()),cfl_view_value_at(),cfl_view_get(). Scalars are returned in place without allocating.cfl_variantcan be handed to a view, which takes ownership.cfl_view_copy_set()makes the view copy them into its own storage (a lazily created arena, reused across loads).cfl_view_materialize(),cfl_view_materialize_in()(arena) andcfl_view_materialize_at()build native CFL objects from the current content.value,materialize). CFL ships one forcfl_kvlist, withcfl_view_kvlist_commit()to write the edits back to the list, including into arena-backed lists.Views do not replace
cfl_kvlist: a view can always be materialized into one, and the normal containers remain the right choice when throughput is not a concern.How this differs from referenced values. CFL variants can already borrow a string or bytes payload (
referenced). That skips the payload copy, but every pair still costs acfl_kvpair, acfl_variantand a key copy, and every value is decoded whether it is read or not. A view removes that per-pair work: no objects per pair, borrowed keys, values decoded only when read. The Fluent Bit path this was measured against already uses referenced values and an arena.VIEW.mddocuments the model, the ownership rules, and how to write a backend and an encoder.Compatibility
VIEW.md, the README and the changelog: names, layouts and semantics can change in any release until that notice is removed.cfl_view_find()compares keys byte by byte. This differs fromcfl_kvlist_fetch(), which ignores ASCII case;cfl_view_find_ex()provides that behavior.Downstream
The intended first consumer is Fluent Bit (log attribute processing);
ctracesattributes are the natural second one. No consumer needs changes for this PR. I validated it against a Fluent Bit tree ported to this API: build, unit tests under Valgrind, focused integration tests normally and under strict Valgrind, and an A/B run showing no CPU change against the in-tree version of the same code.Testing
cfl-test-view: ten cases covering kvlist reads of every type, edit + commit ordering, typed literals, copy mode, owned objects, arena-backed lists, a backend over data that is not made of CFL objects, and table growth.cfl-test-viewis clean under Valgrind (--leak-check=full) and under ASan + UBSan, and passes under MemorySanitizer locally.cfl_view.his part of the self-contained header checks, and the installed-consumer fixture uses a view.-Wall -Wextra) with gcc gnu99, gcc gnu17 and clang gnu99.CI fixes included
Two small commits unrelated to views, needed for a green run on any branch:
scripts: clear CDPATH with an explicit empty stringfixes the Shellcheck SC1007 failure inscripts/agent-*.sh.ci: reduce address randomization for the sanitizer jobsfixesclang-sanitize-memory, which has failed on every run (includingmaster) sinceubuntu-latestmoved to Ubuntu 26.04. A different set of tests segfaulted each time, including programs with an emptymain(). The job now lowersvm.mmap_rnd_bitson the runner before the Clang 11 analysis container starts.