From patchwork Mon Mar 4 15:40:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 13580809 Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) (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 8AAB4481D1 for ; Mon, 4 Mar 2024 15:40:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566815; cv=none; b=bbn6UVv51OfI3dH5MgutE2yZ8DjBGpAXv+Pj0EH8GY3ZRhSb8KJ6yh2HiYVFrepiCG1KwZCB/kHzpRYzS6KyERCc3q10UgEuruysHYCtEkovHTeIm8+ZFvfHG+FbrbCYdeGgqhfQBZ/lF56Hnu4EIaZpMeFP935L+yYGgUG6x2Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566815; c=relaxed/simple; bh=smkKSBjFfk9GhWeZEx4dPXGAWodL+yzJaQFC5xg7tRE=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=pM56+1Bsc4wZno1nHjHpq0NwDepSz8TIiDISqJZ56FKLD1Jguv04LL4sYfiyhsFeclssofjjf2LCMcFF264/L2NXE5GTocN3CTMwH7FX16ZIBoDvr3J+TxKMZ3dXuzwZikAiU5Xj20caXlzOP3xL+pUYYhdYxshg761K7HAt+cw= 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=GDHyKlWv; arc=none smtp.client-ip=209.85.221.42 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="GDHyKlWv" Received: by mail-wr1-f42.google.com with SMTP id ffacd0b85a97d-33ddd1624beso2993965f8f.1 for ; Mon, 04 Mar 2024 07:40:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709566812; x=1710171612; 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=GDHyKlWvmaVXLSM4alk1QfDFQbfwXVFc0zJ6qMIlIAYIGzepQ1JqPuCWGs5Cz1FvkA HG6e97nVraFxA6nrtw584c61LzY9buQkNU57NyJb6HDfrO5p6peUKBO7BWG0ruIpowza bm87VoAbBmIpInW9oX57+knDRaM56ytmEavxO7u8km7yYnlVcDIcONxMort2vYm0ierr ufe51lPkwP/G6Tt//dsJvQAJfc6BApC4QBUCtAPbMDJdBjdoE+SswOn5HsZg/P7qkCM9 t1y7xvDowk+ZfjjVJylyM/9CE/M49o+wJN1/3ijV5ZySjzqEQS0XhG1ltJNBhKUahFCq zNpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709566812; x=1710171612; 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=HLHYAYsekkRzHXVwri7q1wR7kxKfDbjExGL6ifVU7rWSem4zPNwr4sITH0nEwkqTex xk3PxuogQz2hV18EK6v18a36fA/pfS7MVd17IlzOnjJrYqssxY1HBzz2sEOyHJbV4VXI IaaVIuy2Q5TCAq9rhnlnFqwABqb7c19eAdpLfy+6hY3sAo8GSdBaqf+zlXnXLQHbiF3g OMLAMKRunDZ0iCZb27suit7+KelWpQjE9PXVhiXeb6Ckr5OKiwOlCOzMc6XnV71NXvzq xe9JKI2QyUWHcwghiuu4h6Cv9fExfnvpCzSBJmPeIY8aBtUaFFxdWOkYK3uZokTaH2Yg HCyw== X-Gm-Message-State: AOJu0YyYs5L0X2Nizs1zniHGRVXajylB0qh4bN2PhgHjYQnjAeZsXfA+ GcU1dXF0rFwoIqSMCgegvM2PUxOcffY1hWInWbUOcCPJb4U89CnrMaixn1iQ X-Google-Smtp-Source: AGHT+IEP8d3qSki3nfVPA2aNQ3bR+I4NJoPvtuDWq7zOPDdJCQPZHGV8DyMViHpbf0P6o+Zs2tZ+lg== X-Received: by 2002:adf:edc4:0:b0:33d:3c0c:ad53 with SMTP id v4-20020adfedc4000000b0033d3c0cad53mr9205142wro.30.1709566811355; Mon, 04 Mar 2024 07:40:11 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id by12-20020a056000098c00b0033e25c39ac3sm7782685wrb.80.2024.03.04.07.40.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:40:11 -0800 (PST) Message-ID: In-Reply-To: References: Date: Mon, 04 Mar 2024 15:40:05 +0000 Subject: [PATCH 1/4] 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: 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 Mon Mar 4 15:40:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 13580810 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 B40D8482C9 for ; Mon, 4 Mar 2024 15:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566816; cv=none; b=tSC/y+fXIiOrhl1QnbgpzLD/fxOibYHKw07iqKq2mc35p2u7xKu/2DB8BndNooeMMt9zky2aqWLqcIg5ihjTvN0c9mnscinBzyD6r2Gfif7dSWMW594XCQt6iueRn1ojRnMjxHNXfZjQGv19FpZDuvVaBvKKBQ3hhnGIwHD+wRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566816; c=relaxed/simple; bh=m20nHkEJ9M9RgMnpiunE57cAJy/LUOenPGO0EFxA04U=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=kUyspQQ3GyCt5Z+s0yu/DmGRbzEWpFaZ1Kr+FT/HurGT0rTFecCpjjRB05DsqG6GgenS0l6/Boh026N8r8yoHbwy/+TKpkRSL4xmKflhq7Ax5qxwpbhlFrQorUjd6PFEsKQueNkLCNZoA21h7jjSgGWCexY8OWx3LcrJcr6Ov6w= 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=U6jnhKKw; arc=none smtp.client-ip=209.85.221.47 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="U6jnhKKw" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-33ddd1624beso2993976f8f.1 for ; Mon, 04 Mar 2024 07:40:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709566813; x=1710171613; 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=U6jnhKKwahBGLCBa8FDghpJrdXaVbhefG7nzI7LjrZ3YTB6MGKTztWp6b2xUek2EIX tdHp31JKRZpUKjUNJmG451UNG5z4Be1plGEK8criZy/sEWFQsCwfuJrf7lvYvuqBbUuS nxw/NSz0mP/venpo6HEa8pEPx21AFHpRmWvq6CWQrAsihPAtx90GC2nIYDDPLTle+3xz ciywcuyPszf+UT/xGLmLRze96Hg9YQ1WSDnI/OGbc5OfmFkyY7SRWhSWbrlFB46SsxlH 3sxWBWF6VYvOquYgSH9ry+IH+uqJ2nxufvpqdk80wqRKJknXBxAPF9OsZVzmpnuLl87X 3ZDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709566813; x=1710171613; 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=tZFTVn2MxyUYc9MJ+FckEZe7QSM1fsCFPdxU0pVvCVtq3EFoCtdehyzMcO1mUwadeL vd9CWSLrFHQ2d4nO5Xn6d6/DK5GQolVHjYNI/lAnOxrYKU4wnSfmXDYPTK9n5vbEcyF9 cU4aGgNx46sZ0H6m4q0JfnfOmooIapsUIwbfGY1Xej2XSOoobNF48F/PO3HXyCp9UrYR 8wSTHYvEnrtVB59TjiEiLBP1wfs3soZHDMamAWjTjh0HB80LeR/zTfhvxdgWUqcjd5q6 k0hqqFWZFVv3zPa4BOYzuu9vVb9wD7sDe8t9ac6jzpPdfGgM07tPBLU7+euNr9fUj5PH eCsg== X-Gm-Message-State: AOJu0YyjKHXkshbnhci7XyeNLIoMho7NrsMLw8i/ARTnm0I7FYGXFhsH PyTM8e1nTsngRCAxGzfy095gZD0d2QuRz18EYsMPm/hIR1QpH0SIQQ9mMXV7 X-Google-Smtp-Source: AGHT+IHKmhB5hn1+Lg6a5kTMTXnqxmYXaDDTF8ZkiqtonVZJgRfWxrxUAd2x8JvU3tZ1ss0iyCC6nA== X-Received: by 2002:adf:e58a:0:b0:33e:1c3b:9638 with SMTP id l10-20020adfe58a000000b0033e1c3b9638mr8496655wrm.19.1709566812440; Mon, 04 Mar 2024 07:40:12 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bp3-20020a5d5a83000000b0033e431950c5sm1831636wrb.97.2024.03.04.07.40.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:40:11 -0800 (PST) Message-ID: <65068e97597241e297f5d7cdb60012be1784e9dc.1709566808.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 04 Mar 2024 15:40:06 +0000 Subject: [PATCH 2/4] 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: 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 Mon Mar 4 15:40:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 13580811 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 70EB153371 for ; Mon, 4 Mar 2024 15:40:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566817; cv=none; b=QDH3aMFlQSPN789is4XNMyMQORTFsE5jWk/0ls0lkKv9MspkuVU83voxI1oP6A1nOy7NJQQZFE7NLNYsjQPJQFssIi5YfkYb1RCIsvZKIn57ncCF3F7l9AxOe/PuUWqFwwFd93ZEyzKcuq+I3qu7o1rLZIVKP+cltLVbTjsBBbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566817; c=relaxed/simple; bh=lNrxEkFKPGuAxmMK1ggXciDwS5CXYt2lWRAMpk8TSr4=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=OZlcaNlxE7GRbIV8e0Yg4I60j8FcjfdRaySvUYXxYLe5NtfzPEuWMhkucnQ4d60fXOpw+of1ZF/z4msCBjXSqu3fMCQjn1yVEuC+sc7tOIIvP2XYPAsBNMe0P8XVzQMhBwGo0pTOvpWfIf3zVBbhzcjmPC95882SDaiLioSz+JU= 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=fBRccRrk; arc=none smtp.client-ip=209.85.128.49 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="fBRccRrk" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-412e88369a0so3824725e9.0 for ; Mon, 04 Mar 2024 07:40:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709566813; x=1710171613; 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=eEf419t5X95hibsTlXgcE37OBZrjlXQnHzO/EoEeR+M=; b=fBRccRrk2U+aAkCpmjK70hG5CkH5SWAIAmAfAdaMkzppf/dm7AUSv+FKlNDky7/Nxr iGUhkc2BoWddl19c2ir/P8kgpDvep9d6po0l47uuKi+uKK6x7ipNLFNNCzP4qw1syk1m V2VnGwJ2uPv0AG0P9Ln7M559rWRiolrgCZh+ItxLa1KFfyRila9brGnEOyn29JeXvy93 IQ2IWMt16awVrgEECh1T0d/HE4ZYEpc0jlLTrJ2NJOEI8cAu0JYD5E0jcwKfbPHRWjRc +6cusXpNyhSaRmpfrHFRiKRoOuiza63MnvO3Irf5a/k04ULSpY4l5jSIh4G3fDYsnvsT H0/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709566813; x=1710171613; 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=eEf419t5X95hibsTlXgcE37OBZrjlXQnHzO/EoEeR+M=; b=lMitXwyXC50d0au1Gql0YWGRSIlAUtLfNCA+vNGDAG6zNKaAIrAYF6bvM21ANhDqgs 8I+igfizupFr31/+IPQI/CN4laXr4pqcWlecn2LaB555BLXWi1Rf0gEoDHB27aq0b5Ag 10/ZzuYpBGYycQVlVhKPJYnAflVsja0Fd//rcklPCfD66zzGd5qXzRmX8ytikHbazWZx EgSBPx7ESFnjvbrOp3+9v1h4TmsxGLV18QQ8bAbBicQid8Cvsic0Gv9H7Dx2CQZ4PMR/ c6g4afWdqCL66lnTA6SZ1BC0j/9kQtI/CBRUWmJcDQiUfbVLrk9stgOhY3JB7iEbS/it vAsQ== X-Gm-Message-State: AOJu0YwYXGHsDGjk3L1QJb1ggbF/0xNEShouoSGlu29gdN9ilrNiGNCC K9qoyh2QWXiTYAm4iov35+G/1JPpa9qj2l8pPSyyksi8/2OwUGKxb9PfjS6R X-Google-Smtp-Source: AGHT+IFTti8zKO6Vc5R8mZApAImB0lSodOw9EbXU6V/5TY6xwKhkDa3N4ndRYcGs3cCVtoZCzN7EbA== X-Received: by 2002:a05:600c:4f4a:b0:412:a8e0:ca38 with SMTP id m10-20020a05600c4f4a00b00412a8e0ca38mr6185443wmq.40.1709566813078; Mon, 04 Mar 2024 07:40:13 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s16-20020a05600c45d000b00412b67388f0sm17264944wmo.6.2024.03.04.07.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:40:12 -0800 (PST) Message-ID: <9507184b4f1147be529898023d8d504819596f71.1709566808.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 04 Mar 2024 15:40:07 +0000 Subject: [PATCH 3/4] 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: 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. We can later remove explicit calls to "trace2_cmd_list_config()" and "trace2_cmd_list_env_vars()" in git.c. Signed-off-by: Jeff Hostetler --- t/t0211-trace2-perf.sh | 6 +++--- trace2.c | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) 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) From patchwork Mon Mar 4 15:40:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Hostetler X-Patchwork-Id: 13580812 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 A0466535A5 for ; Mon, 4 Mar 2024 15:40:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566817; cv=none; b=HgwzPdlPcLO3CTcmmXz7YcdS4njnu12FCKRDcJAJDGVkS2l4WGNLy0+Dw/6RTpH7e0BWKD1IbyKV/2ZJNySiOGUPJWW2wvTlrB73qjgQV/55QHUOTqOqmm9TuHk9FFm2HseNHgUCmXQZ3hw6m9W6hOWWCVnJG1EgarqoaVybUtE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709566817; c=relaxed/simple; bh=/6XjPCQfCK88zqSmtHg4thraqzB32RUGnA5qkqUfD1k=; h=Message-ID:In-Reply-To:References:From:Date:Subject:Content-Type: MIME-Version:To:Cc; b=MPq2PJho1wcFbwboC03Hrw6Hwep5umQhAiG1nnCfQRl5aGl3FSOTRYiGpzMiVQETpBMuRBxXio65JiTCbkWPtBDQdQ1eKunWyVVsTYDLcs7luadvK1bKTLOeh/Cblh5DH2VRKpzQsxD1Yq1R6Z6HVITfOyosFzJzlklOcRCH10I= 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=fqDUlFnG; arc=none smtp.client-ip=209.85.221.46 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="fqDUlFnG" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-33d38c9ca5bso2316550f8f.2 for ; Mon, 04 Mar 2024 07:40:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709566813; x=1710171613; 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=lUC3q276op1jsCHLT3RlYgbnu50CJW0BM6mhbg0YK4s=; b=fqDUlFnGcPDZR8qZUD+lOnXwP7CWledUYMbbGxx59e5BptaQ7dXEa/P20JWH4myaiB yjQ6PYxVMNA7om7x/Lq2vX0OMxdL6xytoggEBlL2kPkSwdSNJvc4Lut7xpxLZA1ea835 Dk5f6aWrlTG1bmIyfkKvmBuNuskhhq1S847mwnCpgRKpUAOCDbkiXJ/m0r2YOzD1Lry0 Re0MaowzPzHdT6U/IBlgUJA9qWucVJ/Cepe1JePhN9WlHn+8F6sYB0jDWS1cu4kn30EN TxbyAwq7JRnuWiH+8GWxj49AplGlkXbkWQqyh9Zq4IApXaekm0XyHsQ9WB3Zs7PdBlDJ ncnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709566813; x=1710171613; 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=lUC3q276op1jsCHLT3RlYgbnu50CJW0BM6mhbg0YK4s=; b=ED8RDicXp/ncher712SN+63YCCiNqxcXgKSAou19xQeQKzZYmzshPbFiaAw2l0c/+b PMvvuSudn6cysA93OMaPEpVFLoiAunJLrrndo/r1D225O9CwpkUzdRTh4+jXBExN/Qbf ghXpTg0AqEai1phxY9cjLz55vPRK1qkut/UjZt3G39m3nU07dfHc/e8c1in7ydScrXV6 mauxFNrBY0MaRh9R5kiyGPhrVvobKFFdVyZ9smcbUXoV/sb5tB900b7AB6kictbN5H/e sdX6DfMIKBLY6Y6e/wIxL2lixXoxpz+NMPH2L3GrarazHh8g+u9rmuU0FCjBjhchc9fd m5Bw== X-Gm-Message-State: AOJu0YxPnjAUVPTVTVbkbhTznDTkiSQRFeDO7q3mlhOI90TW9DXb7ZBB f7Z5ARi0uMM7q1YThHL678ZRJJ6L1idlRDaGXDQXtSXc7jScu3nIaxG15egA X-Google-Smtp-Source: AGHT+IFleJ2pwCZkJ47cznuOmkz/TMzgx1rgh0qFQ8SKTO2S6EspUbXInUhd8L3RKL29T/nOOU/PgA== X-Received: by 2002:a5d:4b07:0:b0:33d:8ef8:c10c with SMTP id v7-20020a5d4b07000000b0033d8ef8c10cmr6355956wrq.23.1709566813562; Mon, 04 Mar 2024 07:40:13 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bw1-20020a0560001f8100b0033d6bc17d0esm12832598wrb.74.2024.03.04.07.40.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 07:40:13 -0800 (PST) Message-ID: In-Reply-To: References: Date: Mon, 04 Mar 2024 15:40:08 +0000 Subject: [PATCH 4/4] trace2: remove unneeded calls to generate 'def_param' set 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: Jeff Hostetler , Jeff Hostetler From: Jeff Hostetler From: Jeff Hostetler Now that "trace2_cmd_name()" implicitly calls "trace2_cmd_list_config()" and "trace2_cmd_list_env_vars()", we don't need to explicitly call them. Signed-off-by: Jeff Hostetler Reviewed-by: Josh Steadmon --- git.c | 6 ------ 1 file changed, 6 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);