From 860311f89eb866cdbc4470538b58b34cf9879c21 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2026 01:00:17 +0000 Subject: [PATCH 1/2] perf(runtime): memoize related features only for features that declare the relationship Co-Authored-By: jason.han --- changes/unreleased/related-features-memo.fixed.md | 7 +++++++ internal/exec/runtime/subsetting.go | 3 +++ 2 files changed, 10 insertions(+) create mode 100644 changes/unreleased/related-features-memo.fixed.md diff --git a/changes/unreleased/related-features-memo.fixed.md b/changes/unreleased/related-features-memo.fixed.md new file mode 100644 index 0000000000..7219e2eef2 --- /dev/null +++ b/changes/unreleased/related-features-memo.fixed.md @@ -0,0 +1,7 @@ +The runtime's memo of the features a feature's relationships name, per owner type (#1626), +no longer records the features that declare no relationship of the kind asked for, which were +most of its entries and grew with every type an instantiation touched. `FeaturesOf` over +7 000 types allocates 285 MB per run instead of 310 MB, and a cold `Instantiate` 230 MB +instead of 252 MB, recovering most of what #1626 added over 0.11.0's 273 MB and 221 MB on +the same toolchain; the memoized walks of the features that do relate stay memoized, so +repeated reads still allocate nothing and `GRPCVerifyConstraint` is unchanged. diff --git a/internal/exec/runtime/subsetting.go b/internal/exec/runtime/subsetting.go index 6d1ac39532..24ad48aa0f 100644 --- a/internal/exec/runtime/subsetting.go +++ b/internal/exec/runtime/subsetting.go @@ -29,6 +29,9 @@ import ( // A declaration that itself restates sym (`:>> elements` on an object, walked past // its library chain) masks nothing on that walk: the target stays the resolved one. func (ctx *Context) relatedFeatures(sym, owner *symbols.Symbol, kind ast.RelationshipKind) []*symbols.Symbol { + if len(ctx.relationshipsOfKind(sym, kind)) == 0 { + return nil + } key := relatedKey{sym, owner, kind} if features, ok := ctx.model.related[key]; ok { return features From 497a28521e367ab87710b34f3015a9422aa61683 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Fri, 30 Oct 2026 06:38:01 +0000 Subject: [PATCH 2/2] docs(changes): write the fragment as the list item the changelog check requires Co-Authored-By: jason.han --- changes/unreleased/related-features-memo.fixed.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/changes/unreleased/related-features-memo.fixed.md b/changes/unreleased/related-features-memo.fixed.md index 7219e2eef2..434deed4c1 100644 --- a/changes/unreleased/related-features-memo.fixed.md +++ b/changes/unreleased/related-features-memo.fixed.md @@ -1,7 +1 @@ -The runtime's memo of the features a feature's relationships name, per owner type (#1626), -no longer records the features that declare no relationship of the kind asked for, which were -most of its entries and grew with every type an instantiation touched. `FeaturesOf` over -7 000 types allocates 285 MB per run instead of 310 MB, and a cold `Instantiate` 230 MB -instead of 252 MB, recovering most of what #1626 added over 0.11.0's 273 MB and 221 MB on -the same toolchain; the memoized walks of the features that do relate stay memoized, so -repeated reads still allocate nothing and `GRPCVerifyConstraint` is unchanged. +- The runtime's memo of the features a feature's relationships name, per owner type (#1626), no longer records the features that declare no relationship of the kind asked for, which were most of its entries and grew with every type an instantiation touched. `FeaturesOf` over 7 000 types allocates 285 MB per run instead of 310 MB, and a cold `Instantiate` 230 MB instead of 252 MB, recovering most of what #1626 added over 0.11.0's 273 MB and 221 MB on the same toolchain; the memoized walks of the features that do relate stay memoized, so repeated reads still allocate nothing and `GRPCVerifyConstraint` is unchanged.