Repository navigation
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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.
SRX address-book construction repeatedly calls Python subnet comparisons while scanning each network group's existing entries. This change adds an optional Rust extension that batches those comparisons and returns indices into the original Python objects.
Capirca continues to use the existing Python implementation when the extension is absent. Installing Capirca itself does not require Rust. The extension is built separately with
python -m pip install ./nativeand requires Python 3.9+ and Rust 1.83+.The insertion behavior is preserved: the first overlapping network determines the result, equal existing entries are replaced together, and later contained networks remain in place. Python retains address objects, comments, tokens, ordering, and address-book list identity. Scoped IPv6 addresses and custom network subclasses use the Python implementation.
Performance
Complete CLI invocations against upstream
fcca84f5df6e8262d55ecca20635c166009c2c09, using the bundled policies, default options except--max_renderers=1, and an Apple M4:These measurements include process startup, imports, definition loading, parsing, rendering, and file writes. All 49 output files in the complete sample run matched byte-for-byte. Each workload has three measured runs per backend after warm-up, with alternating order and warm filesystem caches.
A separate five-round comparison with address optimization enabled includes a Python integer implementation of the same batching and comparisons. That control captures much of the improvement; Rust is another 1.22x faster across all samples and 2.20x faster on the large mixed-target sample. These are bundled fixtures, including synthetic large networks, rather than a production policy corpus.
Raw results, environment, and reproduction commands.
Validation