[Git][ghc/ghc][master] testsuite: extend size performance tests with gzip (fixes #25046)
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Wed Aug 7 15:49:07 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
eb1cb536 by Serge S. Gulin at 2024-08-06T08:54:55+00:00
testsuite: extend size performance tests with gzip (fixes #25046)
The main purpose is to create tests for minimal app (hello world and its variations, i.e. unicode used) distribution size metric.
Many platforms support distribution in compressed form via gzip. It would be nice to collect information on how much size is taken by the executional bundle for each platform at minimal edge case.
2 groups of tests are added:
1. We extend javascript backend size tests with gzip-enabled versions for all cases where an optimizing compiler is used (for now it is google closure compiler).
2. We add trivial hello world tests with gzip-enabled versions for all other platforms at CI pipeline where no external optimizing compiler is used.
- - - - -
6 changed files:
- testsuite/driver/testlib.py
- + testsuite/tests/perf/size/Makefile
- testsuite/tests/perf/size/all.T
- testsuite/tests/perf/size/javascript/Makefile
- − testsuite/tests/perf/size/javascript/T24602_perf_size.hs
- testsuite/tests/perf/size/javascript/all.T
Changes:
=====================================
testsuite/driver/testlib.py
=====================================
@@ -1426,9 +1426,24 @@ async def test_common_work(name: TestName, opts,
if needsTargetWrapper():
opts.skip = True
elif func in [makefile_test, run_command]:
- # makefile tests aren't necessarily runtime or compile-time
+ # Note [Makefile tests are supposed to be run in all ways]
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ # Makefile tests aren't necessarily runtime or compile-time
# specific. Assume we can run them in all ways. See #16042 for what
# happened previously.
+ #
+ # For example, the WASM test environment requires a target wrapper to run tests
+ # which is why Makefile tests are skipped by default. For cases where the
+ # target wrapper is actually not needed we can trigger Makefile tests to run
+ # by using something like `pre_cmd('$MAKE -s --no-print-directory...`.
+ # Examples of this can be found throughout the code.
+ #
+ # Additionally, it is useful to set `multimod_compile` as the running mode
+ # because it provides enough flexibility to specify source names to compile
+ # without wasting time on running.
+ #
+ # `ignore_stdout` and `ignore_stderr` could also be helpful in cases where
+ # all you need is to compare the exit code with 0.
all_ways = config.compile_ways + config.run_ways
if needsTargetWrapper():
opts.skip = True
=====================================
testsuite/tests/perf/size/Makefile
=====================================
@@ -0,0 +1,11 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
+
+size_hello_artifact_gzip:
+ '$(TEST_HC)' $(TEST_HC_OPTS) ./size_hello_artifact.hs -v0 -fforce-recomp
+ gzip --best "./size_hello_artifact$(exe_extension_from_python)"
+
+size_hello_unicode_gzip:
+ '$(TEST_HC)' $(TEST_HC_OPTS) ./size_hello_unicode.hs -v0 -fforce-recomp
+ gzip --best "./size_hello_unicode$(exe_extension_from_python)"
=====================================
testsuite/tests/perf/size/all.T
=====================================
@@ -3,8 +3,20 @@ test('size_hello_obj', [collect_size(5, 'size_hello_obj.o')], compile, [''])
test('size_hello_artifact', [collect_size(5, 'size_hello_artifact' + exe_extension())],
compile_artifact, [''])
+test('size_hello_artifact_gzip', [extra_files(['./size_hello_artifact.hs']),
+ collect_size(5, 'size_hello_artifact' + exe_extension() + '.gz'),
+ # See Note [Makefile tests are supposed to be run in all ways] in testsuite/driver/testlib.py
+ pre_cmd('$MAKE -s --no-print-directory size_hello_artifact_gzip' + ' exe_extension_from_python="' + exe_extension() + '"'), ignore_stdout, ignore_stderr],
+ multimod_compile, ['size_hello_artifact', ''])
+
test('size_hello_unicode', [collect_size(5, 'size_hello_unicode' + exe_extension())], compile_artifact, [''])
+test('size_hello_unicode_gzip', [extra_files(['./size_hello_unicode.hs']),
+ collect_size(5, 'size_hello_unicode' + exe_extension() + '.gz'),
+ # See Note [Makefile tests are supposed to be run in all ways] in testsuite/driver/testlib.py
+ pre_cmd('$MAKE -s --no-print-directory size_hello_unicode_gzip' + ' exe_extension_from_python="' + exe_extension() + '"'), ignore_stdout, ignore_stderr],
+ multimod_compile, ['size_hello_unicode', ''])
+
size_acceptance_threshold = 100
test('array_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'array')] , static_stats , [] )
=====================================
testsuite/tests/perf/size/javascript/Makefile
=====================================
@@ -3,7 +3,7 @@ include $(TOP)/mk/boilerplate.mk
include $(TOP)/mk/test.mk
T24602_perf_size:
- '$(TEST_HC)' $(TEST_HC_OPTS) ./T24602_perf_size.hs -v0 -fforce-recomp
+ '$(TEST_HC)' $(TEST_HC_OPTS) ./size_hello_artifact.hs -v0 -fforce-recomp
google-closure-compiler \
--platform java \
--warning_level QUIET \
@@ -11,5 +11,23 @@ T24602_perf_size:
--assume_function_wrapper \
--compilation_level ADVANCED_OPTIMIZATIONS \
--emit_use_strict \
- --js_output_file ./T24602_perf_size.jsexe/all.min.js \
- ./T24602_perf_size.jsexe/all.js ./T24602_perf_size.jsexe/all.externs.js
+ --js_output_file ./size_hello_artifact.jsexe/all.min.js \
+ ./size_hello_artifact.jsexe/all.js ./size_hello_artifact.jsexe/all.externs.js
+
+T25046_perf_size_gzip: T24602_perf_size
+ gzip --best ./size_hello_artifact.jsexe/all.min.js
+
+T25046_perf_size_unicode:
+ '$(TEST_HC)' $(TEST_HC_OPTS) ./size_hello_unicode.hs -v0 -fforce-recomp
+ google-closure-compiler \
+ --platform java \
+ --warning_level QUIET \
+ --isolation_mode IIFE \
+ --assume_function_wrapper \
+ --compilation_level ADVANCED_OPTIMIZATIONS \
+ --emit_use_strict \
+ --js_output_file ./size_hello_unicode.jsexe/all.min.js \
+ ./size_hello_unicode.jsexe/all.js ./size_hello_unicode.jsexe/all.externs.js
+
+T25046_perf_size_unicode_gzip: T25046_perf_size_unicode
+ gzip --best ./size_hello_unicode.jsexe/all.min.js
=====================================
testsuite/tests/perf/size/javascript/T24602_perf_size.hs deleted
=====================================
@@ -1,3 +0,0 @@
-module Main where
-
-main = print "Hello, JavaScript!"
=====================================
testsuite/tests/perf/size/javascript/all.T
=====================================
@@ -1,4 +1,7 @@
# These are JavaScript-specific tests based on Google Closure Compiler
setTestOpts(when(not(js_arch()),skip))
-test('T24602_perf_size', [collect_size(5, './T24602_perf_size.jsexe/all.min.js')], makefile_test, ['T24602_perf_size'])
+test('T24602_perf_size', [extra_files(['../size_hello_artifact.hs']), collect_size(5, './size_hello_artifact.jsexe/all.min.js')], makefile_test, ['T24602_perf_size'])
+test('T25046_perf_size_gzip', [extra_files(['../size_hello_artifact.hs']), collect_size(5, './size_hello_artifact.jsexe/all.min.js.gz')], makefile_test, ['T25046_perf_size_gzip'])
+test('T25046_perf_size_unicode', [extra_files(['../size_hello_unicode.hs']), collect_size(5, './size_hello_unicode.jsexe/all.min.js')], makefile_test, ['T25046_perf_size_unicode'])
+test('T25046_perf_size_unicode_gzip', [extra_files(['../size_hello_unicode.hs']), collect_size(5, './size_hello_unicode.jsexe/all.min.js.gz')], makefile_test, ['T25046_perf_size_unicode_gzip'])
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eb1cb53647ff8770a29510a198b829a2426a5108
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/eb1cb53647ff8770a29510a198b829a2426a5108
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240807/9f87fb06/attachment-0001.html>
More information about the ghc-commits
mailing list