diff --git a/raw_memory_test.go b/raw_memory_test.go index 3275ec0..98a1128 100644 --- a/raw_memory_test.go +++ b/raw_memory_test.go @@ -84,8 +84,8 @@ func Test_Syscall6(t *testing.T) { } func Test_LineAlloc(t *testing.T) { - userSize, num := unsafe.Sizeof(User{}), 1000000000 - fmt.Println(heapRawMemoryBytes*8, unsafe.Sizeof(User{})*1000000000) + userSize, num := unsafe.Sizeof(User{}), 10000 + fmt.Println(heapRawMemoryBytes*8, unsafe.Sizeof(User{})*uintptr(num)) size := int(round(uintptr(heapRawMemoryBytes*8), 4096)) addr := uintptr(sysReserve(size)) // 必须预留的多才可以 arena linearAlloc学习这个 prot, flags, fd, offset, length := syscall.PROT_READ|syscall.PROT_WRITE, syscall.MAP_ANON|syscall.MAP_FIXED|syscall.MAP_PRIVATE, -1, 0, size diff --git a/span_pool_test.go b/span_pool_test.go index 474c7fe..ed4f1e3 100644 --- a/span_pool_test.go +++ b/span_pool_test.go @@ -88,7 +88,7 @@ func TestSpanLock(t *testing.T) { func Test_SanPool_Alloc(t *testing.T) { f := &Factory{} - mm, err := f.CreateConcurrentHashMapMemory(0.6, 1) + mm, err := f.CreateMemory(0.6) if err != nil { panic(err) } diff --git a/xmm.go b/xmm.go index 67fa261..992557d 100644 --- a/xmm.go +++ b/xmm.go @@ -142,6 +142,7 @@ type Factory struct { sp *xSpanPool } +// CreateMemory spanFact为负载因子,当span内存超过这个百分比阈值,就会扩容 func (s *Factory) CreateMemory(spanFact float32) (XMemory, error) { if spanFact <= 0 { return nil, NilError @@ -159,24 +160,6 @@ func (s *Factory) CreateMemory(spanFact float32) (XMemory, error) { return &mm{sp: sp, sa: sa, h: h}, nil } -//NewXConcurrentHashMapSpanPool -func (s *Factory) CreateConcurrentHashMapMemory(spanFact float32, pageNumCoefficient uint8) (XMemory, error) { - if spanFact <= 0 { - return nil, NilError - } - h, err := newXHeap() - if err != nil { - return nil, err - } - sp, err := newXConcurrentHashMapSpanPool(h, spanFact, pageNumCoefficient) - if err != nil { - return nil, err - } - sa := newXStringAllocator(sp) - s.sp = sp - return &mm{sp: sp, sa: sa, h: h}, nil -} - func (s *Factory) PrintStatus() { for index, u := range s.sp.inuse { if u < 100 { diff --git a/xmm_test.go b/xmm_test.go index f01e6b6..42dd323 100644 --- a/xmm_test.go +++ b/xmm_test.go @@ -404,7 +404,7 @@ func Test_NewUser(t *testing.T) { func Test_FromInAddr(t *testing.T) { f := &Factory{} - mm, err := f.CreateConcurrentHashMapMemory(0.6, 1) + mm, err := f.CreateMemory(0.6) if err != nil { t.Fatal(err) }