Skip to content

Remove non-determinsim tolerance from code size tests. NFC #19348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2023
Merged
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
8 changes: 4 additions & 4 deletions test/code_size/random_printf_wasm.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"a.html": 12778,
"a.html.gz": 6975,
"total": 12778,
"total_gz": 6975
"a.html": 12770,
"a.html.gz": 6971,
"total": 12770,
"total_gz": 6971
}
24 changes: 2 additions & 22 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -7812,6 +7812,7 @@ def check_expected_size_in_file(self, desc, filename, size):
print(' seen %s size: %d (expected: %d) (delta: %d), ratio to expected: %f' % (desc, size, expected_size, delta, ratio))
self.assertLess(ratio, size_slack)

@crossplatform
def test_unoptimized_code_size(self):
# We don't care too about unoptimized code size but we would like to keep it
# under control to a certain extent. This test allows us to track major
Expand Down Expand Up @@ -10014,6 +10015,7 @@ def test(args, closure, opt):
'math': ('math', False),
'hello_wasm_worker': ('hello_wasm_worker', False, True),
})
@crossplatform
def test_minimal_runtime_code_size(self, test_name, js, compare_js_output=False):
smallest_code_size_args = ['-sMINIMAL_RUNTIME=2',
'-sENVIRONMENT=web',
Expand Down Expand Up @@ -10144,28 +10146,6 @@ def get_file_gzipped_size(f):
print('size of ' + f + ' == ' + str(size) + ', expected ' + str(expected_size) + ', delta=' + str(size - expected_size) + print_percent(size, expected_size))
print('size of ' + f_gz + ' == ' + str(size_gz) + ', expected ' + str(expected_size_gz) + ', delta=' + str(size_gz - expected_size_gz) + print_percent(size_gz, expected_size_gz))

# Hack: Generated .mem initializer files have different sizes on different
# platforms (Windows gives x, CircleCI Linux gives x-17 bytes, my home
# Linux gives x+2 bytes..). Likewise asm.js files seem to be affected by
# the LLVM IR text names, which lead to asm.js names, which leads to
# difference code size, which leads to different relooper choices,
# as a result leading to slightly different total code sizes.
# Also as of July 16, 2020, wasm2js files have different sizes on
# different platforms (Windows and MacOS improved to give a slightly
# better thing than Linux does, which didn't change; this just
# started to happen on CI, not in response to a code update, so it
# may have been present all along but just noticed now; it only
# happens in wasm2js, so it may be platform-nondeterminism in closure
# compiler).
# TODO: identify what is causing this. meanwhile allow some amount of slop
if not common.EMTEST_REBASELINE:
if js:
slop = 30
else:
slop = 20
if size <= expected_size + slop and size >= expected_size - slop:
size = expected_size

# N.B. even though the test code above prints out gzip compressed sizes, regression testing is done against uncompressed sizes
# this is because optimizing for compressed sizes can be unpredictable and sometimes counterproductive
total_output_size += size
Expand Down