Skip to content
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
25 changes: 25 additions & 0 deletions perfkitbenchmarker/disk_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,29 @@ def SetUpDiskOnLinux(self):
self.vm.scratch_disks.append(smb_disk)


def _PreconditionDisk(vm, scratch_disk):
"""Preconditions a raw disk device using fio."""
# pylint: disable=g-import-not-at-top
from perfkitbenchmarker import linux_packages
logging.info(
'Preconditioning disk %s on %s', scratch_disk.GetDevicePath(), vm.name
)
# Ensure the install directory exists
vm.RemoteCommand(
f'sudo mkdir -p {linux_packages.INSTALL_DIR} && '
f'sudo chmod a+rwxt {linux_packages.INSTALL_DIR}'
)
vm.Install('fio')
device_path = scratch_disk.GetDevicePath()
fio_path = f'{linux_packages.INSTALL_DIR}/fio/fio'
cmd = (
f'sudo {fio_path} --filename={device_path} --ioengine=libaio '
f'--name=precondition --blocksize=1M --iodepth=64 '
f'--rw=write --direct=1 --fallocate=none --size=100%'
)
vm.RobustRemoteCommand(cmd)


class PrepareScratchDiskStrategy:
"""Strategies to prepare scratch disks."""

Expand Down Expand Up @@ -375,6 +398,8 @@ def PrepareLinuxScratchDisk(
if disk_spec.mount_point and not vm.IsMounted(
disk_spec.mount_point, scratch_disk.GetDevicePath()
):
if FLAGS.precondition_disks:
_PreconditionDisk(vm, scratch_disk)
vm.FormatDisk(scratch_disk.GetDevicePath(), disk_spec.disk_type)
vm.MountDisk(
scratch_disk.GetDevicePath(),
Expand Down
12 changes: 12 additions & 0 deletions perfkitbenchmarker/linux_packages/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@
'max_memory': '108.8G',
'nr_hugepages': '23000',
},
'SIZE_64G': { # 3TB DB (200 tables, 60M tablesize) for read/write
'shared_buffers': '64GB',
'effective_cache_size': '94GB',
'max_memory': '120G',
'nr_hugepages': '35000',
},
'SIZE_32G': { # 3TB DB (200 tables, 60M tablesize) for read-only
'shared_buffers': '32GB',
'effective_cache_size': '94GB',
'max_memory': '120G',
'nr_hugepages': '25000',
},
}

POSTGRES_CLUSTER_NAME = 'main'
Expand Down
17 changes: 15 additions & 2 deletions perfkitbenchmarker/linux_virtual_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@
[_DEFAULT_DISK_FS_TYPE, 'xfs'],
'File system type used to format disk.',
)
flags.DEFINE_bool(
'precondition_disks',
False,
'Precondition scratch disks using fio before formatting.',
)
flags.DEFINE_integer(
'disk_block_size',
None,
Expand Down Expand Up @@ -582,6 +587,7 @@ def _SetupRobustCommand(self):
if not self._has_remote_command_script:
# Python is needed for RobustRemoteCommands
self.Install('python')
self._CreateVmTmpDir()

for f in (EXECUTE_COMMAND, WAIT_FOR_COMMAND):
remote_path = os.path.join(vm_util.VM_TMP_DIR, os.path.basename(f))
Expand Down Expand Up @@ -1334,9 +1340,16 @@ def FormatDisk(self, device_path, disk_type=None):
fmt_cmd = 'sudo mkfs.xfs -f -i size={} {}'.format(block_size, device_path)
else:
block_size = FLAGS.disk_block_size or 4096
mke2fs_options = 'lazy_itable_init=0'
if FLAGS.precondition_disks:
mke2fs_options += ',nodiscard'
else:
mke2fs_options += ',discard'
fmt_cmd = (
'sudo mke2fs -F -E lazy_itable_init=0,discard -O '
'^has_journal -t ext4 -b {} {}'.format(block_size, device_path)
'sudo mke2fs -F -E {} -O '
'^has_journal -t ext4 -b {} {}'.format(
mke2fs_options, block_size, device_path
)
)
self.os_metadata['disk_filesystem_type'] = FLAGS.disk_fs_type
self.os_metadata['disk_filesystem_blocksize'] = block_size
Expand Down