Skip to content
This repository has been archived by the owner on Mar 9, 2019. It is now read-only.

Commit

Permalink
Merge pull request #218 from benbjohnson/fix-win
Browse files Browse the repository at this point in the history
Fix Windows mmap sizing.
  • Loading branch information
benbjohnson committed Jul 10, 2014
2 parents d9a0f51 + e903703 commit ca5f582
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion db.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (db *DB) munmap() error {
// mmapSize determines the appropriate size for the mmap given the current size
// of the database. The minimum size is 4MB and doubles until it reaches 1GB.
func (db *DB) mmapSize(size int) int {
if size < minMmapSize {
if size <= minMmapSize {
return minMmapSize
} else if size < maxMmapStep {
size *= 2
Expand Down
3 changes: 2 additions & 1 deletion db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ func TestDB_mmapSize(t *testing.T) {
assert.Equal(t, db.mmapSize(0), minMmapSize)
assert.Equal(t, db.mmapSize(16384), minMmapSize)
assert.Equal(t, db.mmapSize(minMmapSize-1), minMmapSize)
assert.Equal(t, db.mmapSize(minMmapSize), minMmapSize*2)
assert.Equal(t, db.mmapSize(minMmapSize), minMmapSize)
assert.Equal(t, db.mmapSize(minMmapSize+1), (minMmapSize*2)+4096)
assert.Equal(t, db.mmapSize(10000000), 20000768)
assert.Equal(t, db.mmapSize((1<<30)-1), 2147483648)
assert.Equal(t, db.mmapSize(1<<30), 1<<31)
Expand Down

0 comments on commit ca5f582

Please sign in to comment.