Repository navigation
Conversation
…that do not change
This was referenced Nov 23, 2026
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.
Part of #542. This is the second step after #814: a batch and a commit no longer copy the sets that do not change.
What this does
Arc).NftSet::elemsis anArc<BTreeMap>. Each change of the elements goes throughNftSet::elems_mut(Arc::make_mut).gccopies the elements only if an element has expired.merge_dynamiccopies them only ifdynsethas changes.ProgElemshas the keys, the ranges, the catch-all element, the stateful expressions, the times of expiry and the timeouts.ProgSethas the parts of one program: the index of each jump chain in the program, the fields, thedynsetchanges, the size, the count and the timeout.ProgElemsis a local index intoProgElems::jumps(the chain handles). EachProgSetmaps these to the chain indexes of its program.NftSet::prog(ProgCache) keeps theProgElemsof the last commit and the elements that it came from. The batch copy and the committed copy of a set share it. At a commit,prog_setuses the cachedProgElemsif the elements of the set are the sameArc(Arc::ptr_eq). Else it makes them again and puts them in the cache.ProgElemscannot become wrong.elems_mutremoves the cache entry before the change, so that the cache does not keep the old elements.NFT_SET_OBJECT) has the state of the objects in its data, so a commit makes itsProgElemsagain each time, as before.Tests
cargo fmt --checkpasses, andcargo test -p rk-netpasses (189 tests).The work of a batch and of a commit
The counters of #814 exist only in the tests.
COPIEDcounts the elements that a copy of a set copies. A new counter,BUILT, counts the elements that the commits put in the programs.The new test
the_programs_share_the_elements_of_a_set_that_did_not_changehas:vmap @m, and a base chain c2 withlookup @sthenjump c12, thenvmap @m.Focused tests/shell, release kernels of this branch
The list is the one of #814: the slow sets and maps tests, the tests that use sets with timeouts, rule_management/0011reset_0 and sets/reset_command_0. Each run used
--timeout 1800.hangat 1800 s on arm64, as in the run of nf_tables: an insert in a set with timeouts does not go through the set, and a get does not copy it #814.hangat 1800 s on arm64 in the run with 2 VMs. It passed in the run of nf_tables: an insert in a set with timeouts does not go through the set, and a get does not copy it #814. So it ran again alone on server2 (1 VM,--timeout 1800), with this branch and with main:The time on arm64 depends on the load of the host: in these kernels the guest clock runs slow (#813, fixed on main by #823 after these runs), so the elements expire late and the maps get large. The run at a low load is a little faster than main. The hang in the run with 2 VMs comes from the load, not from this change.
The wall time under TCG goes mostly to nft and bash in the VM, so this PR claims no large speed-up of these tests. sets/automerge_0 writes to its set in each batch, and no chain uses the set.
The full tests/shell did not run.
The full gate did not run.