From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS24940 94.130.0.0/16 X-Spam-Status: No, score=-3.0 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_HI, SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY shortcircuit=no autolearn=no autolearn_force=no version=3.4.2 Received: from nue.mailmanlists.eu (nue.mailmanlists.eu [94.130.110.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id D7ED31F910 for ; Fri, 25 Nov 2022 21:55:33 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.b="CWEkGIis"; dkim-atps=neutral Received: from nue.mailmanlists.eu (localhost [127.0.0.1]) by nue.mailmanlists.eu (Postfix) with ESMTP id 25F927E596; Fri, 25 Nov 2022 21:54:45 +0000 (UTC) Authentication-Results: nue.mailmanlists.eu; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ruby-lang.org header.i=@ruby-lang.org header.a=rsa-sha256 header.s=s1 header.b=CWEkGIis; dkim-atps=neutral Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by nue.mailmanlists.eu (Postfix) with ESMTPS id 253437E512 for ; Fri, 25 Nov 2022 15:22:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ruby-lang.org; h=from:references:subject:mime-version:content-type: content-transfer-encoding:list-id:to:cc; s=s1; bh=vpHHr5Ph/4nTJgD2OqIUJY1IDsxACvEMs3QMBRq7+jE=; b=CWEkGIisY8nC6zhY7sRLmbsLEvBybNpAUL4s9tE7J7hJNkWoZf7X4YrpuFmP378bBdUq fKRcefAaFCvvmPBsXDmPRL2m5KNhjOyOV864BbrOvFWg936PJtkSOvYJBdyrmclYg92sp6 6qVd37Rs02Hw8IF7b7QXGxSVaoN/5BOyWiTYlMWRdCLHbtDZtmvDZxwn44+xygxLth+N58 Xlc9W3as9rNF6Ulti5EAcjhqqF/rBUIS3hfronPIcsNdsjPABDjyUEIQIdJnSJZajPeLzO de2VX6rTB5P/YGULNgRXj6jWnRh/nHbmWp62kVafkObsmAv9KWobxJPOLO1W8jEg== Received: by filterdrecv-557d69979-wtjx8 with SMTP id filterdrecv-557d69979-wtjx8-1-6380DDB2-D 2022-11-25 15:22:26.334360314 +0000 UTC m=+663396.637550187 Received: from herokuapp.com (unknown) by geopod-ismtpd-3-5 (SG) with ESMTP id b-CtYIDxSLun3qLCfQmbFQ for ; Fri, 25 Nov 2022 15:22:26.187 +0000 (UTC) Date: Fri, 25 Nov 2022 15:22:26 +0000 (UTC) From: "jaruga (Jun Aruga)" Message-ID: References: Mime-Version: 1.0 X-Redmine-Project: ruby-master X-Redmine-Issue-Tracker: Misc X-Redmine-Issue-Id: 19149 X-Redmine-Issue-Author: jaruga X-Redmine-Sender: jaruga X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-Redmine-MailingListIntegration-Message-Ids: 87354 X-SG-EID: =?us-ascii?Q?8MFEQCfxuhzj2xN4bOwU97LZLvLMvdKraBWyqL2uDEHgSji2Jvow9iwWHnUrVV?= =?us-ascii?Q?k5pTGRuxM8KqD8RSTmRcwLITNoTBufXkRLXBYpZ?= =?us-ascii?Q?eA00S1sc+A6AWNC=2FkjuhP=2F=2FzaUF6yV4bdiok6ql?= =?us-ascii?Q?CI1NmbJs8TyJmUlTMxqGLJeydUHg6OdWgB0xLRj?= =?us-ascii?Q?hIouxICcK+yQK4pUUdOVoNOq0lgmuFlG0ZvVTJp?= =?us-ascii?Q?7tCTvGj51JWfzS2NBZ+7rhvq57S7UraFAHTHZ0R?= =?us-ascii?Q?nZh8XRma1GUUYiA5qQFdg=3D=3D?= To: ruby-core@ml.ruby-lang.org X-Entity-ID: b/2+PoftWZ6GuOu3b0IycA== Message-ID-Hash: G64ROEB56QXO23XWZ5X4SM2QV5FW6KMY X-Message-ID-Hash: G64ROEB56QXO23XWZ5X4SM2QV5FW6KMY X-MailFrom: bounces+313651-b711-ruby-core=ml.ruby-lang.org@em5188.ruby-lang.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list Reply-To: Ruby developers Subject: [ruby-core:111009] [Ruby master Misc#19149] Minimal covered tests with the --enable-yjit case? List-Id: Ruby developers Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Issue #19149 has been updated by jaruga (Jun Aruga). > > This will run YJIT with its default options, which is what most people would use when running YJIT. If you specify `--yjit-call-threshold=1 --yjit-verify-ctx`, it will make YJIT compile every single method and run extra verifications. This is what we do on the CI to be extra thorough, but it will be slower. Checking the commit about YJIT, and reading a document about [Ruby JIT's document](https://developer.squareup.com/blog/rubys-new-jit/), the main feature of the YJIT is to create iseq (Instruction Sequence) uniquely for YJIT, and compile it into YARV code, right? The top main functions are below? * `rb_yjit_iseq_mark` at `iseq.c` * `rb_yjit_compile_iseq` at `vm.c` Running the command below with the Ruby above, the `compiled_iseq_count` was `0`, the `rb_yjit_iseq_mark` and `rb_yjit_compile_iseq` were not executed. ``` $ ruby --yjit --yjit-stats -e 'puts "a"' a ***YJIT: Printing YJIT statistics on exit*** method call exit reasons: (all relevant counters are zero) invokeblock exit reasons: (all relevant counters are zero) invokesuper exit reasons: (all relevant counters are zero) leave exit reasons: (all relevant counters are zero) getblockparamproxy exit reasons: (all relevant counters are zero) getinstancevariable exit reasons: (all relevant counters are zero) setinstancevariable exit reasons: (all relevant counters are zero) opt_aref exit reasons: (all relevant counters are zero) expandarray exit reasons: (all relevant counters are zero) opt_getinlinecache exit reasons: (all relevant counters are zero) invalidation reasons: (all relevant counters are zero) bindings_allocations: 73 bindings_set: 0 compiled_iseq_count: 0 compiled_block_count: 0 compiled_branch_count: 0 freed_iseq_count: 0 invalidation_count: 0 constant_state_bumps: 0 inline_code_size: 0 outlined_code_size: 84 freed_code_size: 0 code_region_size: 12288 yjit_alloc_size: 1763 live_page_count: 1 freed_page_count: 0 code_gc_count: 0 num_gc_obj_refs: 0 object_shape_count: 236 side_exit_count: 0 total_exit_count: 0 total_insns_count: 236517 vm_insns_count: 236517 yjit_insns_count: 0 ratio_in_yjit: 0.0% avg_len_in_yjit: NaN total_exits: 0 ``` Running the command below, the 2 functions above were executed. The `compiled_iseq_count` was `4` non-zero. I feel that the `--yjit-call-threshold=1` is necessary to avoid skipping the functions unintentionally in the tests. ``` $ ruby --yjit --yjit-stats --yjit-call-threshold=1 -e 'puts "a"' a ***YJIT: Printing YJIT statistics on exit*** method call exit reasons: (all relevant counters are zero) invokeblock exit reasons: (all relevant counters are zero) invokesuper exit reasons: (all relevant counters are zero) leave exit reasons: interp_return 1 (100.0%) getblockparamproxy exit reasons: (all relevant counters are zero) getinstancevariable exit reasons: (all relevant counters are zero) setinstancevariable exit reasons: (all relevant counters are zero) opt_aref exit reasons: (all relevant counters are zero) expandarray exit reasons: (all relevant counters are zero) opt_getinlinecache exit reasons: (all relevant counters are zero) invalidation reasons: (all relevant counters are zero) bindings_allocations: 73 bindings_set: 0 compiled_iseq_count: 4 compiled_block_count: 8 compiled_branch_count: 12 freed_iseq_count: 0 invalidation_count: 0 constant_state_bumps: 0 inline_code_size: 1074 outlined_code_size: 603 freed_code_size: 0 code_region_size: 12288 yjit_alloc_size: 21097 live_page_count: 1 freed_page_count: 0 code_gc_count: 0 num_gc_obj_refs: 9 object_shape_count: 236 side_exit_count: 0 total_exit_count: 1 total_insns_count: 236325 vm_insns_count: 236313 yjit_insns_count: 12 ratio_in_yjit: 0.0% avg_len_in_yjit: 12.0 total_exits: 0 ``` And it seems that the `--yjit-verify-ctx` option is defined at . However the option is not defined at . Is it intentionally hidden for users? in the `--help` document? ``` $ ruby -v ruby 3.2.0dev (2022-11-24T06:13:00Z master 66e5200ba4) [x86_64-linux] $ ruby --yjit-call-threshold=1 --yjit-verify-ctx -e 'puts "a"' a $ ruby --help | grep 'yjit' --jit enable JIT for the platform, same as --yjit (experimental) --yjit enable in-process JIT compiler (experimental) yjit in-process JIT compiler (default: disabled) --yjit-stats Enable collecting YJIT statistics --yjit-exec-mem-size=num --yjit-call-threshold=num --yjit-max-versions=num --yjit-greedy-versioning ``` ---------------------------------------- Misc #19149: Minimal covered tests with the --enable-yjit case? https://bugs.ruby-lang.org/issues/19149#change-100259 * Author: jaruga (Jun Aruga) * Status: Open * Priority: Normal ---------------------------------------- In the [Fedora Ruby's RPM recipe file](https://src.fedoraproject.org/rpms/ruby/blob/rawhide/f/ruby.spec), we were running the commands below. ``` $ ./autogen.sh $ ./configure ... $ make $ make check ``` ## What is the minimal covered tests? Now the we want to add the `--enable-yjit` option. Could you tell me what is the minimal covered test commands in the `--enable-yjit` case? ``` $ ./autogen.sh $ ./configure --enable-yjit ... $ make $ ?? ``` Then do we need to run the `make check` 2 times with both with yjit and without yjit as follows? The yjit command options `--yjit-call-threshold=1 --yjit-verify-ctx` comes from the . ``` $ make check $ make check RUN_OPTS="--yjit-call-threshold=1 --yjit-verify-ctx" ``` Or is it good enough to run the `make check` and the specific tests with the yjit options as follows? ``` $ make check $ make test-all RUN_OPTS="--yjit-call-threshold=1 --yjit-verify-ctx" TESTS="test/ruby/{test_yjit_exit_locations.rb,test_yjit.rb}" ``` Or is it good enough to run the `make check` with the YJIT options as follows? ``` $ make check RUN_OPTS="--yjit-call-threshold=1 --yjit-verify-ctx" ``` ## YJIT command options Could you explain why the command options `--yjit-call-threshold=1 --yjit-verify-ctx` above is better to test the YJIT cases rather than just `--yjit`? ## Ideal situation I want to see the just running `make check` covers necessary cases in YJIT. Because it is convenience, and I think users tend to be satisfied with only running the `make check`. What do you think? ``` $ ./autogen.sh $ ./configure --enable-yjit ... $ make $ make check ``` I tried to inject the YJIT command options in a test file for that. Perhaps it might be like this. But so far I am not succeeded. ``` diff --git a/test/lib/jit_support.rb b/test/lib/jit_support.rb index 26f8542dc2..3fce402e32 100644 --- a/test/lib/jit_support.rb +++ b/test/lib/jit_support.rb @@ -69,8 +69,10 @@ def supported? end def yjit_supported? + return @yjit_supported if defined?(@yjit_supported) # e.g. x86_64-linux, x64-mswin64_140, x64-mingw32, x64-mingw-ucrt - RUBY_PLATFORM.match?(/^(x86_64|x64|arm64|aarch64)-/) + @yjit_supported = RbConfig::CONFIG["YJIT_SUPPORT"] != 'no' && + RUBY_PLATFORM.match?(/^(x86_64|x64|arm64|aarch64)-/) end def remove_mjit_logs(stderr) diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb index 9ab058d97b..10c8e3b891 100644 --- a/test/ruby/test_yjit.rb +++ b/test/ruby/test_yjit.rb @@ -8,7 +8,7 @@ require 'tmpdir' require_relative '../lib/jit_support' -return unless defined?(RubyVM::YJIT) && RubyVM::YJIT.enabled? +return unless JITSupport.yjit_supported? # Tests for YJIT with assertions on compilation and side exits # insipired by the MJIT tests in test/ruby/test_mjit.rb ``` -- https://bugs.ruby-lang.org/