'The idea is to allocate space in front of an expanding db.  If it gets
within 512k of a boundary, it allocates to the next boundary.
Boundaries are 2m, 5m, 10m, 25m, 50m, then every 50m after.'

def _preallocate(self):

    if ((not DB_PREALLOCATION) or (self.db_file == ':memory:')):
        return
    MB = (1024 * 1024)
    def prealloc_points():
        for pm in (1, 2, 5, 10, 25, 50):
            (yield (pm * MB))
        while True:
            pm += 50
            (yield (pm * MB))
    stat = os.stat(self.db_file)
    file_size = stat.st_size
    allocated_size = (stat.st_blocks * 512)
    for point in prealloc_points():
        if (file_size <= (point - (MB / 2))):
            prealloc_size = point
            break
    if (allocated_size < prealloc_size):
        with open(self.db_file, 'rb+') as fp:
            fallocate(fp.fileno(), int(prealloc_size))
