Skip to content

Commit

Permalink
feat: add randomPop for zipset
Browse files Browse the repository at this point in the history
  • Loading branch information
xgzlucario committed Oct 7, 2024
1 parent b59ab85 commit aded80b
Show file tree
Hide file tree
Showing 12 changed files with 751 additions and 732 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
coverage.*
*.aof

.idea/
redis
rotom
8 changes: 3 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ run-gc:
GODEBUG=gctrace=1 go run .

test-cover:
rm -f *.aof
go test ./... -race -coverprofile=coverage.txt -covermode=atomic
go tool cover -html=coverage.txt -o coverage.html
rm coverage.txt
rm *.aof
rm -f *.aof

fuzz-test:
go test -fuzz=FuzzRESPReader

pprof:
go tool pprof -http=:18081 "http://192.168.1.6:6060/debug/pprof/profile?seconds=30"
go tool pprof -http=:18081 "http://192.168.10.139:6060/debug/pprof/profile?seconds=30"

heap:
go tool pprof http://192.168.1.6:6060/debug/pprof/heap
Expand All @@ -26,8 +27,5 @@ build:
CGO_ENABLED=0 \
go build -o rotom -ldflags "-s -w -X main.buildTime=$(shell date +%y%m%d_%H%M%S%z)"

upx:
upx -9 rotom

build-docker:
docker build --build-arg BUILD_TIME=$(shell date +%y%m%d_%H%M%S%z) -t rotom .
11 changes: 6 additions & 5 deletions ae.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"errors"
"github.com/xgzlucario/rotom/internal/dict"
"golang.org/x/sys/unix"
)
Expand Down Expand Up @@ -38,7 +39,7 @@ type AeLoop struct {
timeEventNextId int
stop bool

_fevents []*AeFileEvent // fes cache
events []*AeFileEvent // file events cache
}

func (loop *AeLoop) AddRead(fd int, proc FileProc, extra interface{}) {
Expand Down Expand Up @@ -141,12 +142,12 @@ func AeLoopCreate() (*AeLoop, error) {
fileEventFd: epollFd,
timeEventNextId: 1,
stop: false,
_fevents: make([]*AeFileEvent, 128), // pre alloc
events: make([]*AeFileEvent, 128), // pre alloc
}, nil
}

func (loop *AeLoop) nearestTime() int64 {
var nearest int64 = GetMsTime() + 1000
var nearest = GetMsTime() + 1000
p := loop.TimeEvents
for p != nil {
nearest = min(nearest, p.when)
Expand All @@ -166,15 +167,15 @@ retry:
n, err := unix.EpollWait(loop.fileEventFd, events[:], int(timeout))
if err != nil {
// interrupted system call
if err == unix.EINTR {
if errors.Is(err, unix.EINTR) {
goto retry
}
log.Error().Msgf("epoll wait error: %v", err)
return
}

// collect file events
fes = loop._fevents[:0]
fes = loop.events[:0]
for _, ev := range events[:n] {
if ev.Events&unix.EPOLLIN != 0 {
fe := loop.FileEvents[int(ev.Fd)]
Expand Down
Loading

0 comments on commit aded80b

Please sign in to comment.