Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sfu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alain Takoudjou
sfu
Commits
a6ff98a3
Commit
a6ff98a3
authored
May 20, 2020
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make packet cache cache-friendly.
parent
464bad07
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
packetcache/packetcache.go
packetcache/packetcache.go
+5
-4
packetcache/packetcache_test.go
packetcache/packetcache_test.go
+11
-0
No files found.
packetcache/packetcache.go
View file @
a6ff98a3
...
...
@@ -8,8 +8,9 @@ const BufSize = 1500
type
entry
struct
{
seqno
uint16
length
int
length
uint16
buf
[
BufSize
]
byte
pad
[
32
-
(
BufSize
+
4
)
%
32
]
byte
// avoid false sharing
}
type
Cache
struct
{
...
...
@@ -40,7 +41,7 @@ func seqnoInvalid(seqno, reference uint16) bool {
return
false
}
if
reference
-
seqno
>
0x100
{
if
reference
-
seqno
>
0x100
{
return
true
}
...
...
@@ -99,7 +100,7 @@ func (cache *Cache) Store(seqno uint16, buf []byte) uint16 {
cache
.
entries
[
cache
.
tail
]
.
seqno
=
seqno
copy
(
cache
.
entries
[
cache
.
tail
]
.
buf
[
:
],
buf
)
cache
.
entries
[
cache
.
tail
]
.
length
=
len
(
buf
)
cache
.
entries
[
cache
.
tail
]
.
length
=
uint16
(
len
(
buf
)
)
cache
.
tail
=
(
cache
.
tail
+
1
)
%
len
(
cache
.
entries
)
return
cache
.
first
...
...
@@ -146,7 +147,7 @@ func (cache *Cache) BitmapGet() (bool, uint16, uint16) {
return
false
,
first
,
0
}
for
bitmap
&
1
==
0
{
for
bitmap
&
1
==
0
{
bitmap
>>=
1
first
++
}
...
...
packetcache/packetcache_test.go
View file @
a6ff98a3
...
...
@@ -4,6 +4,7 @@ import (
"bytes"
"math/rand"
"testing"
"unsafe"
"github.com/pion/rtcp"
)
...
...
@@ -54,6 +55,16 @@ func TestCacheOverflow(t *testing.T) {
}
}
func
TestCacheAlignment
(
t
*
testing
.
T
)
{
cache
:=
New
(
16
)
for
i
:=
range
cache
.
entries
{
p
:=
unsafe
.
Pointer
(
&
cache
.
entries
[
i
])
if
uintptr
(
p
)
%
32
!=
0
{
t
.
Errorf
(
"%v: alignment %v"
,
i
,
uintptr
(
p
)
%
32
)
}
}
}
func
TestBitmap
(
t
*
testing
.
T
)
{
value
:=
uint64
(
0xcdd58f1e035379c0
)
packet
:=
make
([]
byte
,
1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment