code: func (db *DB) mmapSize(size int) (int, error) {
  	// Double the size from 32KB until 1GB.
  	for i := uint(15); i <= 30; i++ {
  		if size <= 1<<i {
  			return 1 << i, nil
  		}
  	}
  
  	// Verify the requested size is not above the maximum allowed.
  	if size > maxMapSize {
  		return 0, fmt.Errorf("mmap too large")
  	}
  
  	// If larger than 1GB then grow by 1GB at a time.
  	sz := int64(size)
  	if remainder := sz % int64(maxMmapStep); remainder > 0 {
  		sz += int64(maxMmapStep) - remainder
  	}
  
  	// Ensure that the mmap size is a multiple of the page size.
  	// This should always be true since we're incrementing in MBs.
  	pageSize := int64(db.pageSize)
  	if (sz % pageSize) != 0 {
  		sz = ((sz / pageSize) + 1) * pageSize
  	}
  
  	// If we've exceeded the max size then only grow up to the max size.
  	if sz > maxMapSize {
  		sz = maxMapSize
  	}
  
  	return int(sz), nil
  }
docs: // mmapSize determines the appropriate size for the mmap given the current size
  // of the database. The minimum size is 32KB and doubles until it reaches 1GB.
  // Returns an error if the new mmap size is greater than the max allowed.