Skip to content

Commit

Permalink
enhancing BPM: WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryogrid committed Jul 15, 2024
1 parent a9acafc commit 3e92769
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
12 changes: 6 additions & 6 deletions lib/container/skip_list/skip_list_bench/skip_list_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ func NewWorkArray() *workArray {

func (arr *workArray) Append(val *types.Value) {
arr.posForInit++
randVal := rand.Intn(10)
if randVal < 2 {
arr.arr[arr.posForInit] = &opTypeAndVal{skip_list.SKIP_LIST_OP_REMOVE, val}
} else {
arr.arr[arr.posForInit] = &opTypeAndVal{skip_list.SKIP_LIST_OP_GET, val}
}
//randVal := rand.Intn(10)
//if randVal < 2 {
// arr.arr[arr.posForInit] = &opTypeAndVal{skip_list.SKIP_LIST_OP_REMOVE, val}
//} else {
arr.arr[arr.posForInit] = &opTypeAndVal{skip_list.SKIP_LIST_OP_GET, val}
//}
}

func (arr *workArray) Shuffle() {
Expand Down
10 changes: 9 additions & 1 deletion lib/storage/buffer/buffer_pool_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type BufferPoolManager struct {

// FetchPage fetches the requested page from the buffer pool.
func (b *BufferPoolManager) FetchPage(pageID types.PageID) *page.Page {
getFrame:
// if it is on buffer pool return it
b.mutex.Lock()
if frameID, ok := b.pageTable[pageID]; ok {
Expand Down Expand Up @@ -86,8 +87,13 @@ func (b *BufferPoolManager) FetchPage(pageID types.PageID) *page.Page {
common.ShPrintf(common.DEBUG_INFO, "FetchPage: page=%d is removed from pageTable.\n", currentPage.GetPageId())
}
delete(b.pageTable, currentPage.GetPageId())
b.freeList = append(b.freeList, *frameID)
b.pages[*frameID] = nil
b.mutex.Unlock()
goto getFrame
}
}
b.mutex.Unlock()

//data := make([]byte, common.PageSize)
data := directio.AlignedBlock(common.PageSize)
Expand All @@ -98,7 +104,7 @@ func (b *BufferPoolManager) FetchPage(pageID types.PageID) *page.Page {
if err != nil {
if err == types.DeallocatedPageErr {
// target page was already deallocated
b.mutex.Unlock()
//b.mutex.Unlock()
return nil
}
fmt.Println(err)
Expand All @@ -113,9 +119,11 @@ func (b *BufferPoolManager) FetchPage(pageID types.PageID) *page.Page {
fmt.Sprintf("BPM::FetchPage pin count must be one here when single thread execution!!!. pageId:%d", pg.GetPageId()))
}

b.mutex.Lock()
b.pageTable[pageID] = *frameID
b.pages[*frameID] = pg
b.mutex.Unlock()
//b.mutex.Unlock()

if common.EnableDebug {
common.ShPrintf(common.DEBUG_INFO, "FetchPage: PageId=%d PinCount=%d\n", pg.GetPageId(), pg.PinCount())
Expand Down
2 changes: 2 additions & 0 deletions lib/storage/disk/virtual_disk_manager_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package disk
import (
"errors"
"fmt"
"runtime"
"strings"
"sync"

Expand Down Expand Up @@ -64,6 +65,7 @@ spin:
// accessing thread exists
// do spin
d.dbFileMutex.Unlock()
runtime.Gosched()
goto spin
}
} else {
Expand Down

0 comments on commit 3e92769

Please sign in to comment.