Reduce descriptor marshal allocations on Go 1.26.4/linux-amd64 (#4681)

* Reduce descriptor marshal allocations on Go 1.26.4/linux-amd64

Signed-off-by: Perfloop Agent <agent@perfloop.ai>

* Use require in the descriptor marshal benchmark test

Signed-off-by: Perfloop Agent <agent@perfloop.ai>

* sfu: marshal dependency descriptors into caller-owned scratch

* sfu: reuse the selector's descriptor clone

* sfu: share one inline header-extension size constant

---------

Signed-off-by: Perfloop Agent <agent@perfloop.ai>
This commit is contained in:
Perfloop Agent
2026-09-30 23:11:49 +08:00
committed by GitHub
parent 2fab31691b
commit 7ef0cd014e
11 changed files with 490 additions and 43 deletions
+11 -2
View File
@@ -199,7 +199,9 @@ type TranslationParams struct {
isResuming bool
isSwitching bool
rtp TranslationParamsRTP
ddBytes []byte
ddBytes [dd.MaxInlineExtensionSize]byte
ddBytesLen int
ddBytesSpill []byte
incomingHeaderSize int
codecBytes [codecmunger.MaxHeaderSize]byte
codecBytesLen int
@@ -213,6 +215,13 @@ func (tp *TranslationParams) codecHeader() []byte {
return tp.codecBytes[:tp.codecBytesLen]
}
// ddInline returns the dependency descriptor extension held inline. It points
// into tp, so it has to be copied before it is attached to anything that
// outlives the write.
func (tp *TranslationParams) ddInline() []byte {
return tp.ddBytes[:tp.ddBytesLen]
}
// -------------------------------------------------------------------
type refInfo struct {
@@ -2190,7 +2199,7 @@ func (f *Forwarder) getTranslationParamsVideo(extPkt *buffer.ExtPacket, layer in
}
tp.isResuming = result.IsResuming
tp.isSwitching = result.IsSwitching
tp.ddBytes = result.DependencyDescriptorExtension
tp.ddBytes, tp.ddBytesLen, tp.ddBytesSpill = result.DDBytes, result.DDBytesLen, result.DDBytesSpill
tp.marker = result.RTPMarker
tp.isEndOfLayerFrame = f.isEndOfLayerFrame(extPkt)