set default minval of knob according to hardware

This commit is contained in:
yangdsh 2019-10-14 18:47:51 +00:00 committed by Dana Van Aken
parent e4a97d060d
commit a2234d08cc
1 changed files with 7 additions and 2 deletions

View File

@ -45,6 +45,9 @@ MEMORY_PERCENT = 0.8
# Percentage of total storage to use for maxval # Percentage of total storage to use for maxval
STORAGE_PERCENT = 0.8 STORAGE_PERCENT = 0.8
# The maximum connections to the database
SESSION_NUM = 50.0
def set_default_knobs(session): def set_default_knobs(session):
dbtype = session.dbms.type dbtype = session.dbms.type
@ -67,16 +70,18 @@ def set_default_knobs(session):
if knob.resource == KnobResourceType.CPU: if knob.resource == KnobResourceType.CPU:
maxval = session.hardware.cpu * CPU_PERCENT maxval = session.hardware.cpu * CPU_PERCENT
elif knob.resource == KnobResourceType.MEMORY: elif knob.resource == KnobResourceType.MEMORY:
minval = session.hardware.memory * minval
maxval = session.hardware.memory * GB * MEMORY_PERCENT maxval = session.hardware.memory * GB * MEMORY_PERCENT
elif knob.resource == KnobResourceType.STORAGE: elif knob.resource == KnobResourceType.STORAGE:
minval = session.hardware.storage * minval
maxval = session.hardware.storage * GB * STORAGE_PERCENT maxval = session.hardware.storage * GB * STORAGE_PERCENT
else: else:
maxval = knob_maxval maxval = knob_maxval
# Special cases # Special cases
if dbtype == DBMSType.POSTGRES: if dbtype == DBMSType.POSTGRES:
if knob.name == 'global.work_mem': if knob.name in ('global.work_mem', 'global.temp_buffers'):
maxval /= 50.0 maxval /= SESSION_NUM
if maxval > knob_maxval: if maxval > knob_maxval:
maxval = knob_maxval maxval = knob_maxval