forked from mirror/ledisdb
use syscall mmap
This commit is contained in:
parent
75c4c59020
commit
501505cea2
|
@ -14,10 +14,6 @@
|
||||||
"Comment": "data/v1-228-g8fb50d5",
|
"Comment": "data/v1-228-g8fb50d5",
|
||||||
"Rev": "8fb50d5ee57110936b904a7539d4c5f2bf2359db"
|
"Rev": "8fb50d5ee57110936b904a7539d4c5f2bf2359db"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"ImportPath": "github.com/edsrzf/mmap-go",
|
|
||||||
"Rev": "6c75090c55983bef2e129e173681b20d24871ef8"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/siddontang/go/arena",
|
"ImportPath": "github.com/siddontang/go/arena",
|
||||||
"Rev": "ecf49fc0738105e87d20e29aa82c403b666ff0b4"
|
"Rev": "ecf49fc0738105e87d20e29aa82c403b666ff0b4"
|
||||||
|
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/edsrzf/mmap-go"
|
|
||||||
"github.com/siddontang/go/log"
|
"github.com/siddontang/go/log"
|
||||||
"github.com/siddontang/go/num"
|
"github.com/siddontang/go/num"
|
||||||
"github.com/siddontang/go/sync2"
|
"github.com/siddontang/go/sync2"
|
||||||
|
@ -13,6 +12,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"sync"
|
"sync"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ type tableReader struct {
|
||||||
index int64
|
index int64
|
||||||
|
|
||||||
f *os.File
|
f *os.File
|
||||||
m mmap.MMap
|
m []byte
|
||||||
|
|
||||||
first uint64
|
first uint64
|
||||||
last uint64
|
last uint64
|
||||||
|
@ -79,7 +79,7 @@ func (t *tableReader) Close() {
|
||||||
|
|
||||||
func (t *tableReader) close() {
|
func (t *tableReader) close() {
|
||||||
if t.m != nil {
|
if t.m != nil {
|
||||||
t.m.Unmap()
|
syscall.Munmap(t.m)
|
||||||
t.m = nil
|
t.m = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ func (t *tableReader) check() error {
|
||||||
return fmt.Errorf("invalid magic data %q", b)
|
return fmt.Errorf("invalid magic data %q", b)
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.m, err = mmap.MapRegion(t.f, int(t.offsetLen), mmap.RDONLY, 0, t.offsetStartPos); err != nil {
|
if t.m, err = syscall.Mmap(int(t.f.Fd()), t.offsetStartPos, int(t.offsetLen), syscall.PROT_READ, syscall.MAP_PRIVATE); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,8 +289,8 @@ func (t *tableReader) openTable() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.m == nil {
|
if t.m == nil {
|
||||||
if t.m, err = mmap.MapRegion(t.f, int(t.offsetLen), mmap.RDONLY, 0, t.offsetStartPos); err != nil {
|
if t.m, err = syscall.Mmap(int(t.f.Fd()), t.offsetStartPos, int(t.offsetLen), syscall.PROT_READ, syscall.MAP_PRIVATE); err != nil {
|
||||||
return fmt.Errorf("mmap %s error %s", t.name, err.Error())
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue