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
+10
View File
@@ -19,6 +19,7 @@ import (
"time"
"github.com/livekit/livekit-server/pkg/sfu/ccutils"
dd "github.com/livekit/livekit-server/pkg/sfu/rtpextension/dependencydescriptor"
"github.com/pion/rtp"
"github.com/pion/webrtc/v4"
)
@@ -59,6 +60,15 @@ type Packet struct {
// the Packet is owned by one send until SendPacket returns
absSendTimeBuf [3]byte
twccBuf [2]byte
extBuf [dd.MaxInlineExtensionSize]byte
}
// HoldExtension copies ext into scratch the header can point at until SendPacket returns, nil if it does not fit
func (p *Packet) HoldExtension(ext []byte) []byte {
if len(ext) > len(p.extBuf) {
return nil
}
return p.extBuf[:copy(p.extBuf[:], ext)]
}
type Pacer interface {