2 @message |
Performance problem
assert
- Median value for 21 ratios of commit_time/compile_time when create 1500 packaged PSQL objects: acceptable
+ Median value for 21 ratios of commit_time/compile_time when create 1500 packaged PSQL objects: /* perf_issue_tag */ UNACCEPTABLE: 0.56 -- greater than threshold = 0.55
+ Check result of 21 measures:
+ 0 : 0.52
+ 1 : 0.55
+ 2 : 0.59
+ 3 : 0.61
+ 4 : 0.56
+ 5 : 0.56
+ 6 : 0.58
+ 7 : 0.55
+ 8 : 0.56
+ 9 : 0.60
+ 10 : 0.52
+ 11 : 0.55
+ 12 : 0.56
+ 13 : 0.51
+ 14 : 0.52
+ 15 : 0.57
+ 16 : 0.56
+ 17 : 0.53
+ 18 : 0.54
+ 19 : 0.56
+ 20 : 0.55
Median value for 21 ratios of commit_time/compile_time when create 1500 standalone PSQL objects: acceptable
LOG DETAILS:
2024-11-23 09:06:20.724
2024-11-23 09:06:20.730 act = <firebird.qa.plugin.Action object at [hex]>
2024-11-23 09:06:20.736 capsys = <_pytest.capture.CaptureFixture object at [hex]>
2024-11-23 09:06:20.741
2024-11-23 09:06:20.747 @pytest.mark.version('>=3.0')
2024-11-23 09:06:20.754 def test_1(act: Action, capsys):
2024-11-23 09:06:20.759
2024-11-23 09:06:20.764 act.db.set_async_write() # just to be sure, although this is by default
2024-11-23 09:06:20.770
2024-11-23 09:06:20.780 expected_stdout = f"""
2024-11-23 09:06:20.785 Median value for {N_MEASURES} ratios of commit_time/compile_time when create {N_LIMIT} packaged PSQL objects: acceptable
2024-11-23 09:06:20.790 Median value for {N_MEASURES} ratios of commit_time/compile_time when create {N_LIMIT} standalone PSQL objects: acceptable
2024-11-23 09:06:20.795 """
2024-11-23 09:06:20.800
2024-11-23 09:06:20.806 func_headers_ddl = ''.join( [ '\n function fn_%d returns int;' % i for i in range(N_LIMIT) ] )
2024-11-23 09:06:20.811 func_bodies_ddl = ''.join( [ '\n function fn_%d returns int as begin return %d; end' % (i,i) for i in range(N_LIMIT) ] )
2024-11-23 09:06:20.817
2024-11-23 09:06:20.823 pkg_header_ddl = '\n'.join( ('create or alter package huge as\nbegin', func_headers_ddl, 'end') )
2024-11-23 09:06:20.831 pkg_body_ddl = '\n'.join( ('recreate package body huge as\nbegin', func_bodies_ddl, 'end') )
2024-11-23 09:06:20.835
2024-11-23 09:06:20.841 sp_time = {}
2024-11-23 09:06:20.847 with act.db.connect() as con:
2024-11-23 09:06:20.853
2024-11-23 09:06:20.858 with con.cursor() as cur:
2024-11-23 09:06:20.864 cur.execute('select mon$server_pid as p from mon$attachments where mon$attachment_id = current_connection')
2024-11-23 09:06:20.871 fb_pid = int(cur.fetchone()[0])
2024-11-23 09:06:20.877
2024-11-23 09:06:20.882 for i in range(0, N_MEASURES):
2024-11-23 09:06:20.886 for ftype in ('packaged', 'standalone'):
2024-11-23 09:06:20.891
2024-11-23 09:06:20.898 fb_info_a = psutil.Process(fb_pid).cpu_times()
2024-11-23 09:06:20.903 if ftype == 'packaged':
2024-11-23 09:06:20.909 con.execute_immediate(pkg_header_ddl)
2024-11-23 09:06:20.915 con.execute_immediate(pkg_body_ddl)
2024-11-23 09:06:20.922 else:
2024-11-23 09:06:20.929 for k in range(0,N_LIMIT):
2024-11-23 09:06:20.935 con.execute_immediate( 'create or alter function sf_%d returns int as begin return %d; end' % (k,k) )
2024-11-23 09:06:20.940
2024-11-23 09:06:20.946 fb_info_b = psutil.Process(fb_pid).cpu_times()
2024-11-23 09:06:20.954 con.commit()
2024-11-23 09:06:20.960 fb_info_c = psutil.Process(fb_pid).cpu_times()
2024-11-23 09:06:20.966
2024-11-23 09:06:20.970 cpu_time_for_compile = max(fb_info_b.user - fb_info_a.user, 0.000001)
2024-11-23 09:06:20.975 cpu_time_for_commit = fb_info_c.user - fb_info_b.user
2024-11-23 09:06:20.983
2024-11-23 09:06:20.988 sp_time[ ftype, i ] = cpu_time_for_commit / cpu_time_for_compile
2024-11-23 09:06:20.994
2024-11-23 09:06:20.999 commit_2_compile_ratio_for_package = [round(v,2) for k,v in sp_time.items() if k[0] == 'packaged']
2024-11-23 09:06:21.005 commit_2_compile_ratio_for_standal = [round(v,2) for k,v in sp_time.items() if k[0] == 'standalone']
2024-11-23 09:06:21.010
2024-11-23 09:06:21.016 actual_time_ratios_commit2compile = { 'packaged' : median(commit_2_compile_ratio_for_package), 'standalone': median(commit_2_compile_ratio_for_standal) }
2024-11-23 09:06:21.021
2024-11-23 09:06:21.027 for ftype in ('packaged', 'standalone'):
2024-11-23 09:06:21.033 msg = f"Median value for {N_MEASURES} ratios of commit_time/compile_time when create {N_LIMIT} {ftype} PSQL objects: "
2024-11-23 09:06:21.038 if actual_time_ratios_commit2compile[ ftype ] < MAX_TIME_RATIOS_COMMIT_TO_COMPILE[ ftype ]:
2024-11-23 09:06:21.043 print( msg + 'acceptable')
2024-11-23 09:06:21.049 else:
2024-11-23 09:06:21.054 print( msg + '/* perf_issue_tag */ UNACCEPTABLE: %12.2f -- greater than threshold = %12.2f' % (actual_time_ratios_commit2compile[ ftype ], MAX_TIME_RATIOS_COMMIT_TO_COMPILE[ ftype ]) )
2024-11-23 09:06:21.059 print( 'Check result of %d measures:' % N_MEASURES )
2024-11-23 09:06:21.064
2024-11-23 09:06:21.069 # List with concrete values (source for median evaluation):
2024-11-23 09:06:21.075 lst = commit_2_compile_ratio_for_package if ftype == 'packaged' else commit_2_compile_ratio_for_standal
2024-11-23 09:06:21.080 for i,p in enumerate(lst):
2024-11-23 09:06:21.085 print('%3d' % i, ':', '%12.2f' % p)
2024-11-23 09:06:21.090
2024-11-23 09:06:21.096
2024-11-23 09:06:21.101 act.expected_stdout = expected_stdout
2024-11-23 09:06:21.107 act.stdout = capsys.readouterr().out
2024-11-23 09:06:21.113 > assert act.clean_stdout == act.clean_expected_stdout
2024-11-23 09:06:21.118 E assert
2024-11-23 09:06:21.124 E - Median value for 21 ratios of commit_time/compile_time when create 1500 packaged PSQL objects: acceptable
2024-11-23 09:06:21.130 E + Median value for 21 ratios of commit_time/compile_time when create 1500 packaged PSQL objects: /* perf_issue_tag */ UNACCEPTABLE: 0.56 -- greater than threshold = 0.55
2024-11-23 09:06:21.135 E + Check result of 21 measures:
2024-11-23 09:06:21.140 E + 0 : 0.52
2024-11-23 09:06:21.146 E + 1 : 0.55
2024-11-23 09:06:21.151 E + 2 : 0.59
2024-11-23 09:06:21.161 E + 3 : 0.61
2024-11-23 09:06:21.167 E + 4 : 0.56
2024-11-23 09:06:21.172 E + 5 : 0.56
2024-11-23 09:06:21.177 E + 6 : 0.58
2024-11-23 09:06:21.183 E + 7 : 0.55
2024-11-23 09:06:21.189 E + 8 : 0.56
2024-11-23 09:06:21.194 E + 9 : 0.60
2024-11-23 09:06:21.199 E + 10 : 0.52
2024-11-23 09:06:21.205 E + 11 : 0.55
2024-11-23 09:06:21.210 E + 12 : 0.56
2024-11-23 09:06:21.215 E + 13 : 0.51
2024-11-23 09:06:21.220 E + 14 : 0.52
2024-11-23 09:06:21.225 E + 15 : 0.57
2024-11-23 09:06:21.231 E + 16 : 0.56
2024-11-23 09:06:21.236 E + 17 : 0.53
2024-11-23 09:06:21.241 E + 18 : 0.54
2024-11-23 09:06:21.246 E + 19 : 0.56
2024-11-23 09:06:21.251 E + 20 : 0.55
2024-11-23 09:06:21.257 E Median value for 21 ratios of commit_time/compile_time when create 1500 standalone PSQL objects: acceptable
2024-11-23 09:06:21.261
2024-11-23 09:06:21.266 tests/bugs/core_4880_test.py:164: AssertionError
2024-11-23 09:06:21.270 ---------------------------- Captured stdout setup -----------------------------
2024-11-23 09:06:21.275 Creating db: localhost:/var/tmp/qa_2024/test_1975/test.fdb [page_size=None, sql_dialect=None, charset='NONE', user=SYSDBA, password=masterkey]
|
3 #text |
act = <firebird.qa.plugin.Action pytest object at [hex]>
capsys = <_pytest.capture.CaptureFixture pytest object at [hex]>
@pytest.mark.version('>=3.0')
def test_1(act: Action, capsys):
act.db.set_async_write() # just to be sure, although this is by default
expected_stdout = f"""
Median value for {N_MEASURES} ratios of commit_time/compile_time when create {N_LIMIT} packaged PSQL objects: acceptable
Median value for {N_MEASURES} ratios of commit_time/compile_time when create {N_LIMIT} standalone PSQL objects: acceptable
"""
func_headers_ddl = ''.join( [ '\n function fn_%d returns int;' % i for i in range(N_LIMIT) ] )
func_bodies_ddl = ''.join( [ '\n function fn_%d returns int as begin return %d; end' % (i,i) for i in range(N_LIMIT) ] )
pkg_header_ddl = '\n'.join( ('create or alter package huge as\nbegin', func_headers_ddl, 'end') )
pkg_body_ddl = '\n'.join( ('recreate package body huge as\nbegin', func_bodies_ddl, 'end') )
sp_time = {}
with act.db.connect() as con:
with con.cursor() as cur:
cur.execute('select mon$server_pid as p from mon$attachments where mon$attachment_id = current_connection')
fb_pid = int(cur.fetchone()[0])
for i in range(0, N_MEASURES):
for ftype in ('packaged', 'standalone'):
fb_info_a = psutil.Process(fb_pid).cpu_times()
if ftype == 'packaged':
con.execute_immediate(pkg_header_ddl)
con.execute_immediate(pkg_body_ddl)
else:
for k in range(0,N_LIMIT):
con.execute_immediate( 'create or alter function sf_%d returns int as begin return %d; end' % (k,k) )
fb_info_b = psutil.Process(fb_pid).cpu_times()
con.commit()
fb_info_c = psutil.Process(fb_pid).cpu_times()
cpu_time_for_compile = max(fb_info_b.user - fb_info_a.user, 0.000001)
cpu_time_for_commit = fb_info_c.user - fb_info_b.user
sp_time[ ftype, i ] = cpu_time_for_commit / cpu_time_for_compile
commit_2_compile_ratio_for_package = [round(v,2) for k,v in sp_time.items() if k[0] == 'packaged']
commit_2_compile_ratio_for_standal = [round(v,2) for k,v in sp_time.items() if k[0] == 'standalone']
actual_time_ratios_commit2compile = { 'packaged' : median(commit_2_compile_ratio_for_package), 'standalone': median(commit_2_compile_ratio_for_standal) }
for ftype in ('packaged', 'standalone'):
msg = f"Median value for {N_MEASURES} ratios of commit_time/compile_time when create {N_LIMIT} {ftype} PSQL objects: "
if actual_time_ratios_commit2compile[ ftype ] < MAX_TIME_RATIOS_COMMIT_TO_COMPILE[ ftype ]:
print( msg + 'acceptable')
else:
print( msg + '/* perf_issue_tag */ UNACCEPTABLE: %12.2f -- greater than threshold = %12.2f' % (actual_time_ratios_commit2compile[ ftype ], MAX_TIME_RATIOS_COMMIT_TO_COMPILE[ ftype ]) )
print( 'Check result of %d measures:' % N_MEASURES )
# List with concrete values (source for median evaluation):
lst = commit_2_compile_ratio_for_package if ftype == 'packaged' else commit_2_compile_ratio_for_standal
for i,p in enumerate(lst):
print('%3d' % i, ':', '%12.2f' % p)
act.expected_stdout = expected_stdout
act.stdout = capsys.readouterr().out
> assert act.clean_stdout == act.clean_expected_stdout
E assert
E - Median value for 21 ratios of commit_time/compile_time when create 1500 packaged PSQL objects: acceptable
E + Median value for 21 ratios of commit_time/compile_time when create 1500 packaged PSQL objects: /* perf_issue_tag */ UNACCEPTABLE: 0.56 -- greater than threshold = 0.55
E + Check result of 21 measures:
E + 0 : 0.52
E + 1 : 0.55
E + 2 : 0.59
E + 3 : 0.61
E + 4 : 0.56
E + 5 : 0.56
E + 6 : 0.58
E + 7 : 0.55
E + 8 : 0.56
E + 9 : 0.60
E + 10 : 0.52
E + 11 : 0.55
E + 12 : 0.56
E + 13 : 0.51
E + 14 : 0.52
E + 15 : 0.57
E + 16 : 0.56
E + 17 : 0.53
E + 18 : 0.54
E + 19 : 0.56
E + 20 : 0.55
E Median value for 21 ratios of commit_time/compile_time when create 1500 standalone PSQL objects: acceptable
tests/bugs/core_4880_test.py:164: AssertionError
|