From patchwork Thu Mar 7 15:22:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 13585881 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 037D2130AC2 for ; Thu, 7 Mar 2024 15:22:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709824956; cv=none; b=gCaT8q0Bpbep28Kt3UaZn610GzjcPA/kcLsm64Fbh9nJ+p3eRT+O+p/w93Kqi5pACaMndD7z/b0mHYNBR5ayKJBsfOSjwqnWjw01ShgKvIFIJSmgCkS6yFp2zrvbV+BEIWaau9sha/w+1GigFeBQfnoAH+IMBtJ7ZpIf+KHPYNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709824956; c=relaxed/simple; bh=smkKSBjFfk9GhWeZEx4dPXGAWodL+yzJaQFC5xg7tRE=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=ub7XmSHG83fZx1NKzWbSmyB7v0XCX4R9TBXxnz1dp764+e/ttrGdr19in3ohspljjJ6ZwM5JxFOwvOArNLTyK367azAigLgNHZa3WS2ONj8IcO7Vk7qpSkLVYuqP+s1hCv37N+S4oxVaaTEXI0ighUNuvbovgwJtJhUL++V7Sd4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hhDs02wQ; arc=none smtp.client-ip=209.85.167.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hhDs02wQ" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-51341a5aafbso1095071e87.0 for ; Thu, 07 Mar 2024 07:22:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709824951; x=1710429751; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=TU83T99cHGoAZca3sEX6lwhqsB1KO5dXBt4kckaA3DQ=; b=hhDs02wQDGoRqexYZUSWMZoNgAacfimjF5F6Q2aSeWAuvRYxsBSK7Ap0GN0z0ly+TL bghytLVw3HOgFcBvgze5xRpR1bxRd5Bo/CMktX+ramumW0OWtjmRDDULpT3qateb/+uj jGLHty+2JcW1uZsBjtbTdTqtDIRjEFpkzGAIG7V51Tt4xExnEzFrSLKVBwn6pPnZElzH /kf7w8liDSUfj+GlEnhKMduCAwlYS7LuCLgn5Y1RyOlIijsbVTvLCkj3sO6kiVcCrF3n H2TYQr3XCE64ySBU0SkfE7lN3iW/GVVWPCiKJuRdzMJ6Hduqb1HaEske04hg1acFKaON OvdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709824951; x=1710429751; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TU83T99cHGoAZca3sEX6lwhqsB1KO5dXBt4kckaA3DQ=; b=Sjf0WjP7pdVbss3pCaooMKKESue6yzoqTG22ClDrEwRxV2DXWF89zHArvqaVI4iJqd j4jZbQArvAoVpZ5OdFja7GYbdYHyzt4ln6n5EPwSUwT+lxNA3caG36SZxwA0S00JeuuL +Rh9icdUSJ0VKmQUK6J7ebvGyFIc/6tdOkzYq25qBGmuz8SLQbZuEEgSDr6NrpzsukIS 39d6nqbrk9hgtWTXbEg8N6xHWnp1MYkzOGqgI4mp68vyJamGPEUA7CJ5uVMhkZeHnKkZ 7ltSP4U242GoJvT87Sil98KvPFbCAZEq7sb/8e6fGpNIWvLTheHbqgPW0ObUa1KWu7Ym HIBg== X-Gm-Message-State: AOJu0YzDY2guPUQFzyQ1kNHwIlxGftzAQFCNvbVpK/T3Ls9FVgfjl78y PNvpeHPD90akPVscwfyISWUNC5C0BOyfayv4C+SwXbQ7M1CB93G0+Qp7IaAT X-Google-Smtp-Source: AGHT+IG3UKxzum31I2lQdT69mUpPe6ehhMwdc5XTSftTgFrF3MHOFpzE0F2J1RScqYZ5EzGjFi1CFg== X-Received: by 2002:a05:6512:1388:b0:512:ee09:a7a5 with SMTP id fc8-20020a056512138800b00512ee09a7a5mr2140746lfb.34.1709824951091; Thu, 07 Mar 2024 07:22:31 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o32-20020a05600c512000b0041312e8ef2bsm1333090wms.26.2024.03.07.07.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 07:22:30 -0800 (PST) Message-ID: In-Reply-To: References: Date: Thu, 07 Mar 2024 15:22:27 +0000 Subject: [PATCH v2 1/3] t0211: demonstrate missing 'def_param' events for certain commands Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Josh Steadmon , Jeff Hostetler , Jeff Hostetler , Jeff Hostetler From: Jeff Hostetler From: Jeff Hostetler Some Git commands fail to emit 'def_param' events for interesting config and environment variable settings. Add unit tests to demonstrate this. Most commands are considered "builtin" and are based upon git.c. These typically do emit 'def_param' events. Exceptions are some of the "query" commands, the "run-dashed" mechanism, and alias handling. Commands built from remote-curl.c (instead of git.c), such as "git-remote-https", do not emit 'def_param' events. Likewise, "git-http-fetch" is built http-fetch.c and does not emit them. Signed-off-by: Jeff Hostetler --- t/t0211-trace2-perf.sh | 231 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 231 insertions(+) diff --git a/t/t0211-trace2-perf.sh b/t/t0211-trace2-perf.sh index 290b6eaaab1..588c5bad033 100755 --- a/t/t0211-trace2-perf.sh +++ b/t/t0211-trace2-perf.sh @@ -287,4 +287,235 @@ test_expect_success 'unsafe URLs are redacted by default' ' grep "d0|main|def_param|.*|remote.origin.url:https://user:pwd@example.com" actual ' +# Confirm that the requested command produces a "cmd_name" and a +# set of "def_param" events. +# +try_simple () { + test_when_finished "rm prop.perf actual" && + + cmd=$1 && + cmd_name=$2 && + + test_config_global "trace2.configParams" "cfg.prop.*" && + test_config_global "trace2.envvars" "ENV_PROP_FOO,ENV_PROP_BAR" && + + test_config_global "cfg.prop.foo" "red" && + + ENV_PROP_FOO=blue \ + GIT_TRACE2_PERF="$(pwd)/prop.perf" \ + $cmd && + perl "$TEST_DIRECTORY/t0211/scrub_perf.perl" actual && + grep "d0|main|cmd_name|.*|$cmd_name" actual && + grep "d0|main|def_param|.*|cfg.prop.foo:red" actual && + grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual +} + +# Representative mainstream builtin Git command dispatched +# in run_builtin() in git.c +# +test_expect_success 'expect def_params for normal builtin command' ' + try_simple "git version" "version" +' + +# Representative query command dispatched in handle_options() +# in git.c +# +test_expect_failure 'expect def_params for query command' ' + try_simple "git --man-path" "_query_" +' + +# remote-curl.c does not use the builtin setup in git.c, so confirm +# that executables built from remote-curl.c emit def_params. +# +# Also tests the dashed-command handling where "git foo" silently +# spawns "git-foo". Make sure that both commands should emit +# def_params. +# +# Pass bogus arguments to remote-https and allow the command to fail +# because we don't actually have a remote to fetch from. We just want +# to see the run-dashed code run an executable built from +# remote-curl.c rather than git.c. Confirm that we get def_param +# events from both layers. +# +test_expect_failure 'expect def_params for remote-curl and _run_dashed_' ' + test_when_finished "rm prop.perf actual" && + + test_config_global "trace2.configParams" "cfg.prop.*" && + test_config_global "trace2.envvars" "ENV_PROP_FOO,ENV_PROP_BAR" && + + test_config_global "cfg.prop.foo" "red" && + + test_might_fail env \ + ENV_PROP_FOO=blue \ + GIT_TRACE2_PERF="$(pwd)/prop.perf" \ + git remote-http x y && + + perl "$TEST_DIRECTORY/t0211/scrub_perf.perl" actual && + + grep "d0|main|cmd_name|.*|_run_dashed_" actual && + grep "d0|main|def_param|.*|cfg.prop.foo:red" actual && + grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual && + + grep "d1|main|cmd_name|.*|remote-curl" actual && + grep "d1|main|def_param|.*|cfg.prop.foo:red" actual && + grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual +' + +# Similarly, `git-http-fetch` is not built from git.c so do a +# trivial fetch so that the main git.c run-dashed code spawns +# an executable built from http-fetch.c. Confirm that we get +# def_param events from both layers. +# +test_expect_failure 'expect def_params for http-fetch and _run_dashed_' ' + test_when_finished "rm prop.perf actual" && + + test_config_global "trace2.configParams" "cfg.prop.*" && + test_config_global "trace2.envvars" "ENV_PROP_FOO,ENV_PROP_BAR" && + + test_config_global "cfg.prop.foo" "red" && + + test_might_fail env \ + ENV_PROP_FOO=blue \ + GIT_TRACE2_PERF="$(pwd)/prop.perf" \ + git http-fetch --stdin file:/// <<-EOF && + EOF + + perl "$TEST_DIRECTORY/t0211/scrub_perf.perl" actual && + + grep "d0|main|cmd_name|.*|_run_dashed_" actual && + grep "d0|main|def_param|.*|cfg.prop.foo:red" actual && + grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual && + + grep "d1|main|cmd_name|.*|http-fetch" actual && + grep "d1|main|def_param|.*|cfg.prop.foo:red" actual && + grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual +' + +# Historically, alias expansion explicitly emitted the def_param +# events (independent of whether the command was a builtin, a Git +# command or arbitrary shell command) so that it wasn't dependent +# upon the unpeeling of the alias. Let's make sure that we preserve +# the net effect. +# +test_expect_success 'expect def_params during git alias expansion' ' + test_when_finished "rm prop.perf actual" && + + test_config_global "trace2.configParams" "cfg.prop.*" && + test_config_global "trace2.envvars" "ENV_PROP_FOO,ENV_PROP_BAR" && + + test_config_global "cfg.prop.foo" "red" && + + test_config_global "alias.xxx" "version" && + + ENV_PROP_FOO=blue \ + GIT_TRACE2_PERF="$(pwd)/prop.perf" \ + git xxx && + + perl "$TEST_DIRECTORY/t0211/scrub_perf.perl" actual && + + # "git xxx" is first mapped to "git-xxx" and the child will fail. + grep "d0|main|cmd_name|.*|_run_dashed_ (_run_dashed_)" actual && + + # We unpeel that and substitute "version" into "xxx" (giving + # "git version") and update the cmd_name event. + grep "d0|main|cmd_name|.*|_run_git_alias_ (_run_dashed_/_run_git_alias_)" actual && + + # These def_param events could be associated with either of the + # above cmd_name events. It does not matter. + grep "d0|main|def_param|.*|cfg.prop.foo:red" actual && + grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual && + + # The "git version" child sees a different cmd_name hierarchy. + # Also test the def_param (only for completeness). + grep "d1|main|cmd_name|.*|version (_run_dashed_/_run_git_alias_/version)" actual && + grep "d1|main|def_param|.*|cfg.prop.foo:red" actual && + grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual +' + +test_expect_success 'expect def_params during shell alias expansion' ' + test_when_finished "rm prop.perf actual" && + + test_config_global "trace2.configParams" "cfg.prop.*" && + test_config_global "trace2.envvars" "ENV_PROP_FOO,ENV_PROP_BAR" && + + test_config_global "cfg.prop.foo" "red" && + + test_config_global "alias.xxx" "!git version" && + + ENV_PROP_FOO=blue \ + GIT_TRACE2_PERF="$(pwd)/prop.perf" \ + git xxx && + + perl "$TEST_DIRECTORY/t0211/scrub_perf.perl" actual && + + # "git xxx" is first mapped to "git-xxx" and the child will fail. + grep "d0|main|cmd_name|.*|_run_dashed_ (_run_dashed_)" actual && + + # We unpeel that and substitute "git version" for "git xxx" (as a + # shell command. Another cmd_name event is emitted as we unpeel. + grep "d0|main|cmd_name|.*|_run_shell_alias_ (_run_dashed_/_run_shell_alias_)" actual && + + # These def_param events could be associated with either of the + # above cmd_name events. It does not matter. + grep "d0|main|def_param|.*|cfg.prop.foo:red" actual && + grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual && + + # We get the following only because we used a git command for the + # shell command. In general, it could have been a shell script and + # we would see nothing. + # + # The child knows the cmd_name hierarchy so it includes it. + grep "d1|main|cmd_name|.*|version (_run_dashed_/_run_shell_alias_/version)" actual && + grep "d1|main|def_param|.*|cfg.prop.foo:red" actual && + grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual +' + +test_expect_failure 'expect def_params during nested git alias expansion' ' + test_when_finished "rm prop.perf actual" && + + test_config_global "trace2.configParams" "cfg.prop.*" && + test_config_global "trace2.envvars" "ENV_PROP_FOO,ENV_PROP_BAR" && + + test_config_global "cfg.prop.foo" "red" && + + test_config_global "alias.xxx" "yyy" && + test_config_global "alias.yyy" "version" && + + ENV_PROP_FOO=blue \ + GIT_TRACE2_PERF="$(pwd)/prop.perf" \ + git xxx && + + perl "$TEST_DIRECTORY/t0211/scrub_perf.perl" actual && + + # "git xxx" is first mapped to "git-xxx" and try to spawn "git-xxx" + # and the child will fail. + grep "d0|main|cmd_name|.*|_run_dashed_ (_run_dashed_)" actual && + grep "d0|main|child_start|.*|.* class:dashed argv:\[git-xxx\]" actual && + + # We unpeel that and substitute "yyy" into "xxx" (giving "git yyy") + # and spawn "git-yyy" and the child will fail. + grep "d0|main|alias|.*|alias:xxx argv:\[yyy\]" actual && + grep "d0|main|cmd_name|.*|_run_dashed_ (_run_dashed_/_run_dashed_)" actual && + grep "d0|main|child_start|.*|.* class:dashed argv:\[git-yyy\]" actual && + + # We unpeel that and substitute "version" into "xxx" (giving + # "git version") and update the cmd_name event. + grep "d0|main|alias|.*|alias:yyy argv:\[version\]" actual && + grep "d0|main|cmd_name|.*|_run_git_alias_ (_run_dashed_/_run_dashed_/_run_git_alias_)" actual && + + # These def_param events could be associated with any of the + # above cmd_name events. It does not matter. + grep "d0|main|def_param|.*|cfg.prop.foo:red" actual >actual.matches && + grep "d0|main|def_param|.*|ENV_PROP_FOO:blue" actual && + + # However, we do not want them repeated each time we unpeel. + test_line_count = 1 actual.matches && + + # The "git version" child sees a different cmd_name hierarchy. + # Also test the def_param (only for completeness). + grep "d1|main|cmd_name|.*|version (_run_dashed_/_run_dashed_/_run_git_alias_/version)" actual && + grep "d1|main|def_param|.*|cfg.prop.foo:red" actual && + grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual +' + test_done From patchwork Thu Mar 7 15:22:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 13585880 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 029BA130AC1 for ; Thu, 7 Mar 2024 15:22:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709824955; cv=none; b=aK5GGHDHsU80DsWhbMiapouZRjffbE14G/Nwv4DWPk2iqyxV1uEosj3fQTJqHXKoFDB7IlVhnSRC3r+0/eIjBphKBq83Enyuae+FxUIv4QsxdjChe7LXZ+Gpw786KZr3C2NOL+GDYagEzaZx6e4bXzW1HJdOgbgcbN0CeCnIq8U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709824955; c=relaxed/simple; bh=m20nHkEJ9M9RgMnpiunE57cAJy/LUOenPGO0EFxA04U=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=gay27USvIpmqq3qo7r6L/waey6JhHEulU8VEPHqF6CBKVH9C0U4usG+MFA7ZzF5bS2pb1sg8YpwF/HKgIs5uI7+1HWzb4ISE3Ko35BCk4ZFKs1wnX3WCOTzyqo9E15G7qGC4yaSijA4rEDlZefmkMV+91KEaSC6CjNS2M0XO4HY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iTAL/0VD; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iTAL/0VD" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-33d6f26ff33so742247f8f.0 for ; Thu, 07 Mar 2024 07:22:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709824952; x=1710429752; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=dgER52tmIvBJG4lqzwRTZ1uvr/BPpXF0FMqkFydmFc4=; b=iTAL/0VDvvHl0i9/MdLruMgpuZJDBCFZdukQNfdOYzy1thfszPgFcsvCoNcOp3rcOL 84KyVxFvTFo2p7sqX6OB75iwNnvnvq1BqE/Wk7xYeLy6SqOfqOX2AnTz4JAbiH68MhNH 0OmFPDhGC/3e8rJQhqiyL7Mfq9eo+8EcfyavmksGNJdhwtY2BfUUuN28fROC7+/yjYHF 8d4Ljx1ApCsgjQwmQQQyqP44QInIbY51hRPHNVaMr8Xz7chrzovDcTInXhTeJCT84hSG vytbnKyvKgJK1SBa+FDhapJAdSO72mTsr/J33Mj+uJy7FoKeHPE0WxXlHXwTiVwj8ui8 nQYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709824952; x=1710429752; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dgER52tmIvBJG4lqzwRTZ1uvr/BPpXF0FMqkFydmFc4=; b=s3bYGpO0vVuR2aO6adSKW8FDZOyeEkw/zqulCYe0ef+Efroe26j5m8Q0+jn1t2n+ZI zHVvvT+MW6S+sRuMTBwXxdJDaTrOcfaCFHShJNKpi118LMFWYPc0U0WMKM9nvOjXvVr/ XEfTy6Q2sZxkZhIpI+Bo4neirCFFOiP1PXIB6nfouc7298EV8sa63MXiUH9TwBFB+QUK WyFMiBZeF3AQUQEI3jzpLqRgt6ixc9++W23PbdlHHNTPIRET1OP/f5nhhQGZ1cKxHXal cD2k6p/UYe9fXt/hTcbW5rYB8qb9uP8NmSom15SzuUxEWcOl9WsU7jNvg4Ukv+BSUZF6 RGgQ== X-Gm-Message-State: AOJu0Ywx4XONt77Y4XHIFIk3AfbO8Aq/Qm14L25DIwGPCHN0Y7I3wvF5 Oq+bGFwKM6S8ngqDHIyd+7zBbW0UhbHCo13DlJiayASAq7SdYsZ7IehyjsJA X-Google-Smtp-Source: AGHT+IEdn5jhhPQ6b37TYcae/l0gJj6SlY/p2kwkNP9hqbvdh7eKdJXkdDqabT5QZwAQlSmSbgdf5g== X-Received: by 2002:a5d:6e48:0:b0:33d:6c9f:39d6 with SMTP id j8-20020a5d6e48000000b0033d6c9f39d6mr13658211wrz.40.1709824951661; Thu, 07 Mar 2024 07:22:31 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id b12-20020a05600003cc00b0033e451a9b64sm9252474wrg.61.2024.03.07.07.22.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 07:22:31 -0800 (PST) Message-ID: <65068e97597241e297f5d7cdb60012be1784e9dc.1709824949.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 07 Mar 2024 15:22:28 +0000 Subject: [PATCH v2 2/3] trace2: avoid emitting 'def_param' set more than once Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Josh Steadmon , Jeff Hostetler , Jeff Hostetler , Jeff Hostetler From: Jeff Hostetler From: Jeff Hostetler During nested alias expansion it is possible for "trace2_cmd_list_config()" and "trace2_cmd_list_env_vars()" to be called more than once. This causes a full set of 'def_param' events to be emitted each time. Let's avoid that. Add code to those two functions to only emit them once. Signed-off-by: Jeff Hostetler --- t/t0211-trace2-perf.sh | 2 +- trace2.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/t/t0211-trace2-perf.sh b/t/t0211-trace2-perf.sh index 588c5bad033..7b353195396 100755 --- a/t/t0211-trace2-perf.sh +++ b/t/t0211-trace2-perf.sh @@ -470,7 +470,7 @@ test_expect_success 'expect def_params during shell alias expansion' ' grep "d1|main|def_param|.*|ENV_PROP_FOO:blue" actual ' -test_expect_failure 'expect def_params during nested git alias expansion' ' +test_expect_success 'expect def_params during nested git alias expansion' ' test_when_finished "rm prop.perf actual" && test_config_global "trace2.configParams" "cfg.prop.*" && diff --git a/trace2.c b/trace2.c index f1e268bd159..facce641ef3 100644 --- a/trace2.c +++ b/trace2.c @@ -464,17 +464,29 @@ void trace2_cmd_alias_fl(const char *file, int line, const char *alias, void trace2_cmd_list_config_fl(const char *file, int line) { + static int emitted = 0; + if (!trace2_enabled) return; + if (emitted) + return; + emitted = 1; + tr2_cfg_list_config_fl(file, line); } void trace2_cmd_list_env_vars_fl(const char *file, int line) { + static int emitted = 0; + if (!trace2_enabled) return; + if (emitted) + return; + emitted = 1; + tr2_list_env_vars_fl(file, line); } From patchwork Thu Mar 7 15:22:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 13585882 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 594DF12F37C for ; Thu, 7 Mar 2024 15:22:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709824957; cv=none; b=EWAhm0p+uG9ht2LYa29oOk2CILM663VRBeppHXNKTDoD1UcZzcg5/Kwal1UrIqF6pqfSf68qbXfH6xbIajkCJbZH1FrdxMXpBn30Gh3tGc+QKMsCF+BC/WRqw6EG4OqRipWlLLfgkyrALvIgRvLwXtBu0bHol+T/7iSiAP98JL0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709824957; c=relaxed/simple; bh=o/eFoZ6g/Xy1LO8y86rCr6PDddqxvZ0+sLCXDazcvTk=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=CYwFq5xmhB75yVAr1+NvWVFSea5ZzE1XujjbuIq1y0RBoYhphyppD6ggg0yO0b2EC5iRYNmNXbdBnt2/KUhqwVaOeDzxx/sCk1Srk+59bHejH1ugLin1sNYIX1JExr3pf5VGXXCMxjUi0NiNTAerSdwJRfACh1N0vmC6rnNUKpc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WlXpDw1W; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WlXpDw1W" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-412f67bc6d0so8572445e9.3 for ; Thu, 07 Mar 2024 07:22:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709824953; x=1710429753; darn=vger.kernel.org; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=KCKPBPxTkJuC8pllkhdDxRMpPlF1FoB0VaaWbadmq2k=; b=WlXpDw1W9WQhIj4LCSDdpq0RKJf6IohtVey2zZ3xeYKqzhX8geEgjnFgEiuudFGV9O 9YHp6ep1pZ9C5+laXSRmMGi6+idnfK/xkbpT9FPlBjd+YmMB3EmWTTLog8PPSVD4loZN ouKu8qI0qq4FO3dYIc9rrbdy/yhE6hqBgV80upm8SvFXv4a6OOiVxxFUN+h5vG/cobOz RDrvmP0FU7+2f9uay/afyJ2JcDeNwCE7J7JC/+gPJV5P2Nl6d6smldPeQlInNG9yM9za 5IKO6JBy+ZiiidrCo5eswirClyAbjZBYlLQ+74Ez6o4czcXZ1dGpdZ1gJlSbR1Jev/nA gx4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709824953; x=1710429753; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KCKPBPxTkJuC8pllkhdDxRMpPlF1FoB0VaaWbadmq2k=; b=JcVQESS6/cOpS5Xb9PewTfxN1Aq78V1V+wBO9tSBsDFF7RzUsT/hYAg+3zF9e9BWuH /wJwsxUtP5d/ob5gWQ571lUJq6btmShApcdkO4LEE+7xvU2rByYUEuIoyxuA2is1IgqC F+n1mVDXOQ7z7i/tslc+j24KFDVKeMycJxPOPjmj0cKV7+7aVtZFgyXODAhgAefmlwmS e6MNmQQpxK6p74YoIxwHWzf+2uwGISE1Czhhn2RjL9ZrLcXeUDw4AIhPnnFI4K+rzYIf 6AiDiSyfr4tpzk/mIUB83EJ1iKngd6EcHoBqxO+g4mFfD8oOfg++r0dVg5ts/Dytz6ri RN+g== X-Gm-Message-State: AOJu0Yw/OCdarz7s+FZWIoQmsgN6JEEwRy3Gp/vtCMQ6lB/3rDnYIA9I f1iOGO8gzc32ohVBhFdh7gc8AmnUp0uVsvSl1sCyuLdAT/KSY0EjVKptEv1N X-Google-Smtp-Source: AGHT+IGrqYYwW2HL8cy9w4gwhgY2NH2RwLt2UUHkSFuARd5ITDKNN5u+ZESeIbAHcr8jcdrFApp4Lg== X-Received: by 2002:a05:600c:3544:b0:412:9eec:92c9 with SMTP id i4-20020a05600c354400b004129eec92c9mr14707683wmq.18.1709824952913; Thu, 07 Mar 2024 07:22:32 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m21-20020a05600c4f5500b004130db58a97sm2959787wmq.39.2024.03.07.07.22.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 07:22:32 -0800 (PST) Message-ID: <178721cd4f044af44b9d7e625cabf63c5e19c75d.1709824949.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 07 Mar 2024 15:22:29 +0000 Subject: [PATCH v2 3/3] trace2: emit 'def_param' set with 'cmd_name' event Fcc: Sent Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To: git@vger.kernel.org Cc: Josh Steadmon , Jeff Hostetler , Jeff Hostetler , Jeff Hostetler From: Jeff Hostetler From: Jeff Hostetler Some commands do not cause a set of 'def_param' events to be emitted. This includes "git-remote-https", "git-http-fetch", and various "query" commands, like "git --man-path". Since all of these commands do emit a 'cmd_name' event, add code to the "trace2_cmd_name()" function to generate the set of 'def_param' events. Remove explicit calls to "trace2_cmd_list_config()" and "trace2_cmd_list_env_vars()" in git.c since they are no longer needed. Reviewed-by: Josh Steadmon Signed-off-by: Jeff Hostetler --- git.c | 6 ------ t/t0211-trace2-perf.sh | 6 +++--- trace2.c | 3 +++ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/git.c b/git.c index 7068a184b0a..a769d72ab8f 100644 --- a/git.c +++ b/git.c @@ -373,8 +373,6 @@ static int handle_alias(int *argcp, const char ***argv) strvec_pushv(&child.args, (*argv) + 1); trace2_cmd_alias(alias_command, child.args.v); - trace2_cmd_list_config(); - trace2_cmd_list_env_vars(); trace2_cmd_name("_run_shell_alias_"); ret = run_command(&child); @@ -411,8 +409,6 @@ static int handle_alias(int *argcp, const char ***argv) COPY_ARRAY(new_argv + count, *argv + 1, *argcp); trace2_cmd_alias(alias_command, new_argv); - trace2_cmd_list_config(); - trace2_cmd_list_env_vars(); *argv = new_argv; *argcp += count - 1; @@ -462,8 +458,6 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv) trace_argv_printf(argv, "trace: built-in: git"); trace2_cmd_name(p->cmd); - trace2_cmd_list_config(); - trace2_cmd_list_env_vars(); validate_cache_entries(the_repository->index); status = p->fn(argc, argv, prefix); diff --git a/t/t0211-trace2-perf.sh b/t/t0211-trace2-perf.sh index 7b353195396..13ef69b92f8 100755 --- a/t/t0211-trace2-perf.sh +++ b/t/t0211-trace2-perf.sh @@ -320,7 +320,7 @@ test_expect_success 'expect def_params for normal builtin command' ' # Representative query command dispatched in handle_options() # in git.c # -test_expect_failure 'expect def_params for query command' ' +test_expect_success 'expect def_params for query command' ' try_simple "git --man-path" "_query_" ' @@ -337,7 +337,7 @@ test_expect_failure 'expect def_params for query command' ' # remote-curl.c rather than git.c. Confirm that we get def_param # events from both layers. # -test_expect_failure 'expect def_params for remote-curl and _run_dashed_' ' +test_expect_success 'expect def_params for remote-curl and _run_dashed_' ' test_when_finished "rm prop.perf actual" && test_config_global "trace2.configParams" "cfg.prop.*" && @@ -366,7 +366,7 @@ test_expect_failure 'expect def_params for remote-curl and _run_dashed_' ' # an executable built from http-fetch.c. Confirm that we get # def_param events from both layers. # -test_expect_failure 'expect def_params for http-fetch and _run_dashed_' ' +test_expect_success 'expect def_params for http-fetch and _run_dashed_' ' test_when_finished "rm prop.perf actual" && test_config_global "trace2.configParams" "cfg.prop.*" && diff --git a/trace2.c b/trace2.c index facce641ef3..f894532d053 100644 --- a/trace2.c +++ b/trace2.c @@ -433,6 +433,9 @@ void trace2_cmd_name_fl(const char *file, int line, const char *name) for_each_wanted_builtin (j, tgt_j) if (tgt_j->pfn_command_name_fl) tgt_j->pfn_command_name_fl(file, line, name, hierarchy); + + trace2_cmd_list_config(); + trace2_cmd_list_env_vars(); } void trace2_cmd_mode_fl(const char *file, int line, const char *mode)