Skip to content

Adding additional APIs and pointing header directly into file #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions advise_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ func (b *Buffer) Advise() error {
b.Lock()
defer b.Unlock()

m := b.readmeta()

// Start of next page above write offset
wo := int(m.woff) + (pageSize - int(m.woff)%pageSize)
wo := int(b.m.woff) + (pageSize - int(b.m.woff)%pageSize)

// Start of page below read offset
ro := int(m.roff) - int(m.roff)%pageSize
ro := int(b.m.roff) - int(b.m.roff)%pageSize

if ro > wo {
return syscall.Madvise(b.data[wo:ro], syscall.MADV_DONTNEED)
Expand All @@ -34,8 +32,8 @@ func (b *Buffer) Advise() error {
return err
}
}
if wo < int(m.cap) {
return syscall.Madvise(b.data[wo:m.cap], syscall.MADV_DONTNEED)
if wo < int(b.m.cap) {
return syscall.Madvise(b.data[wo:b.m.cap], syscall.MADV_DONTNEED)
}
return nil
}
Loading