fix(nrfcache): match filters reject profiles they should accept - #170
Merged
gab-arrobo merged 3 commits intoAug 7, 2026
Merged
Conversation
A cached NF profile that declares no SUPI ranges was rejected whenever a discovery query carried a SUPI, so UDM, PCF and AUSF lookups could never be served from cache and every request fell through to the NRF. The NRF's own discovery filter matches those profiles: its supi filter is an $or over "a range contains the SUPI", "supiRanges is null" and "supiRanges is absent". The cache therefore selected a different set of profiles than the NRF it caches, so a cached lookup and a live discovery disagreed for the same query. Match the NRF semantics in MatchUdmProfile, MatchPcfProfile and MatchAusfProfile, and cover both the unrestricted case and the still-filtered case with regression tests. Measured on an SD-Core deployment whose single UDM/PCF register without SUPI ranges: AMF NRF cache misses per registration dropped from ~4 to 0, NfProfile queries from 21 to 16 per registration, and NRF CPU from 77 ms to 51 ms per registration. Signed-off-by: Ben Grewell <bgrewell@gmail.com>
NrfCache.get drops any cached profile whose NfType has no entry in matchFilters, and UDR had no entry. Cached UDR discovery therefore always returned an empty result, so every UDM and PCF subscriber data access fell through to a live NRF query. That miss is expensive beyond the extra query: handleLookup holds the cache write lock across the NRF round trip, so a permanently-missing NF type serialises every concurrent discovery for it behind one network call. UDR is resolved on every subscriber data access, which makes it the most frequently discovered NF in the core. Add MatchUdrProfile, mirroring the NRF's own UDR supi filter, and register it. Cover the SUPI-range and unrestricted cases, and assert the filter is registered so a future NF type is not silently dropped again. Measured on SD-Core, registration throughput over the same load sweep rose from 22 to ~185 attaches/s, and MongoDB operations per registration fell from 50 to 25 as the NfProfile and urilist queries left the hot path. Signed-off-by: Ben Grewell <bgrewell@gmail.com>
This was referenced Aug 6, 2026
gab-arrobo
requested changes
Aug 6, 2026
Reorder struct to satisfy field alignment lint Co-authored-by: Gabriel Arrobo <gabriel.arrobo@intel.com> Signed-off-by: Ben Grewell <BGrewell@gmail.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (1)
nrfcache/match_filters.go:289
- The inline reference to
nrf producer/nf_discovery.go/[Query-18]appears to point to a file/query that does not exist in this repository, which makes the rationale hard to verify/maintain from this codebase. Consider rewording the comment to describe the behavior without referencing an external path/query label.
// A profile declaring no SUPI ranges is unrestricted and serves every
// SUPI. The NRF's own discovery filter encodes this as an $or over
// "a range contains the SUPI" / "supiRanges is null" / "supiRanges is
// absent" (nrf producer/nf_discovery.go, [Query-18] supi). Rationale:
// the cache must select the same profiles as the NRF it caches,
// otherwise a cached lookup and a live discovery disagree.
gab-arrobo
approved these changes
Aug 7, 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.
Two related defects in
nrfcache/match_filters.go. Both make cached NF discovery return empty for profiles that are valid, so the cache is structurally incapable of hitting and every lookup falls through to the NRF.Both were found and measured against a live Aether SD-Core deployment under registration load, with a 5G SA gNB/UE simulator driving attaches.
1 — Profiles without SUPI ranges are treated as restricted
MatchUdmProfile/MatchPcfProfile/MatchAusfProfilerequire a cached profile to carry a non-emptySupiRangeswhenever the discovery query includes asupi; a profile with no ranges is rejected.SD-Core registers one UDM/PCF serving every subscriber, with no SUPI ranges — verified on the wire, the NRF returns
udmInfo:{"groupId":""}. So the match can never succeed, and the AMF logscache miss for nftype AUSF/UDM/PCFon every attach, preceded bymatch found = false (no SUPI ranges).Per TS 29.510
supiRangesis an optional restriction on an NF profile: a range constrains, and an absent constraint admits everything. The matchers now treat "no SUPI ranges" as unrestricted.2 — No match filter is registered for UDR
matchFiltershas noNFTYPE_UDRentry, andnrfcache.gosilently drops any profile whose NfType has no filter. Cached UDR discovery therefore always returns empty — a permanent miss — after which theEnableNrfCaching && emptyfallback fires a second, direct NRF query. The UDM performs several UDR discoveries per registration, so this sits on the attach hot path.Measured effect
Registering the UDR filter took the test deployment from 22 to ~185 registrations/s (stable across 5 runs, 173–189/s, 100% success), registration P50 400 ms → 256 ms, and MongoDB operations per attach 50 → 25 as
NfProfileandurilistqueries left the hot path. The SUPI-range fix removes the remaining per-attach AUSF/UDM/PCF misses (4 → 0 observed).Testing
Regression tests added for both defects; each fails without its fix.
go test ./nrfcache/passes.Validated live by building the consuming NFs (AMF, UDM) against this branch with a
go mod edit -replaceand re-measuring on the deployment.The two changes share
nrfcache_test.goand the second builds on the first, hence one PR; happy to split if preferred.