this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

internal/core/adt: use grouped allocation for let Vertex and Conjunct

Use a single grouped allocation for the Vertex and its Conjunct slice
in LetReference.resolve, avoiding a separate heap allocation for the
[]Conjunct{c} slice literal. The Conjuncts slice now points into the
same allocation as the Vertex itself.

│ old │ new │
│ B/op │ B/op vs base │
VetInventory 3.504Gi ± ∞ ¹ 3.504Gi ± ∞ ¹ +0.01% (p=1.000 n=1)

│ old │ new │
│ allocs/op │ allocs/op vs base │
VetInventory 30.36M ± ∞ ¹ 30.17M ± ∞ ¹ -0.63% (p=1.000 n=1)

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I9cb81b826f2a62e3cd46072a81089e7e07745923
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1234437
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>

+9 -2
+9 -2
internal/core/adt/expr.go
··· 840 840 if e.cache == nil { 841 841 e.cache = map[cacheKey]Value{} 842 842 } 843 - n := &Vertex{ 843 + // Allocate a vertex with space for one conjunct. 844 + var alloc struct { 845 + v Vertex 846 + c [1]Conjunct 847 + } 848 + alloc.c[0] = c 849 + alloc.v = Vertex{ 844 850 Parent: arc.Parent, 845 851 Label: x.Label, 846 852 IsDynamic: b != nil && b.Code == StructuralCycleError, 847 - Conjuncts: []Conjunct{c}, 853 + Conjuncts: alloc.c[:], 848 854 } 855 + n := &alloc.v 849 856 v = n 850 857 e.cache[key] = n 851 858 // TODO(mem): enable again once we implement memory management.