Skip to content

Commit

Permalink
fix linear_alloc_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhang-Jun-tao committed Feb 15, 2022
1 parent 9a77cd0 commit 7a89158
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 16 deletions.
5 changes: 0 additions & 5 deletions example/mod/go.mod

This file was deleted.

5 changes: 0 additions & 5 deletions example/mod/go.sum

This file was deleted.

1 change: 0 additions & 1 deletion src/README

This file was deleted.

9 changes: 4 additions & 5 deletions src/linear_alloc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestLinearAlloc2(t *testing.T) {
if err != nil {
t.Fatal(err)
}
node := (*entry.NodeEntry)(p)
node := (*NodeEntry)(p)

var wait sync.WaitGroup
wait.Add(10)
Expand Down Expand Up @@ -99,14 +99,14 @@ func TestLinearAlloc3(t *testing.T) {
if err != nil {
t.Fatal(err)
}
fmt.Println(unsafe.Sizeof(entry.NodeEntry{}), uintptr(p), round(uintptr(p), pageSize), unsafe.Offsetof(entry.NodeEntry{}.Next))
fmt.Println(round(unsafe.Sizeof(entry.NodeEntry{}), 8), round(unsafe.Sizeof(A{}), 8))
fmt.Println(unsafe.Sizeof(NodeEntry{}), uintptr(p), round(uintptr(p), pageSize), unsafe.Offsetof(NodeEntry{}.Next))
fmt.Println(round(unsafe.Sizeof(NodeEntry{}), 8), round(unsafe.Sizeof(A{}), 8))

//todo 怀疑是这个内存没有对齐 -120 cache line 0.01s -80 0.09s -20 0.22s
//todo 对齐
ptr := uintptr(p) + pageSize*101 - 1500
fmt.Println(ptr, ptr%8, round(ptr, pageSize), round(ptr+80, pageSize))
node := (*entry.NodeEntry)(unsafe.Pointer(ptr))
node := (*NodeEntry)(unsafe.Pointer(ptr))
var wait sync.WaitGroup
wait.Add(10)
t11 := time.Now()
Expand Down Expand Up @@ -137,5 +137,4 @@ func TestLinearCopyAlloc4(t *testing.T) {
}
ptr := uintptr(p) + pageSize*101 - 1500
fmt.Println(float64(pageSize*101)*0.1/8.0, ptr)

}

0 comments on commit 7a89158

Please sign in to comment.