git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff Hostetler <git@jeffhostetler.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Junio C Hamano" <gitster@pobox.com>
Cc: Jeff Hostetler <jeffhost@microsoft.com>,
	git@vger.kernel.org,
	"Randall S . Becker" <randall.becker@nexbridge.ca>
Subject: Re: [PATCH] trace2 tests: guard pthread test with "PTHREAD"
Date: Mon, 28 Nov 2022 11:37:55 -0500	[thread overview]
Message-ID: <6c725ed6-4d74-c260-98fb-dc965b4647ee@jeffhostetler.com> (raw)
In-Reply-To: <221125.867czjo3ud.gmgdl@evledraar.gmail.com>



On 11/25/22 3:05 AM, Ævar Arnfjörð Bjarmason wrote:
> 
> On Fri, Nov 25 2022, Junio C Hamano wrote:
> 
>> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
>>
>>> Since 81071626ba1 (trace2: add global counter mechanism, 2022-10-24)
>>> these tests have been failing when git is compiled with NO_PTHREADS=Y,
>>> which is always the case e.g. if 'uname -s' is "NONSTOP_KERNEL".
>>>
>>> Reported-by: Randall S. Becker <randall.becker@nexbridge.ca>
>>> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
>>> ---
>>>   t/t0211-trace2-perf.sh | 4 ++--
>>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> Makes sense, to sweep the immediate breakage under prerequisite.

This change LGTM.  The test-tool will report an error trying to
create the requested threads, so there will not be any per-thread
output for the grep to match.


>>
>> But why would a global counter need threading?  I know that the
>> counters can optionally report per-thread stats, but that is
>> optional and it would still be useful if we can count events in a
>> single-threaded program, no?

Timers & counters are accumulated in per-thread local storage.
This allows them to work in a lock-free manner.

Timer/Counter usage by a single-threaded program just accumulates
data in the thread local storage of the "main" thread so that the
code is the same in all cases.

Global timers and counters are accumulated from per-thread ones during
thread-exit.  (See calls to `tr2_update_final_timers()` and
`tr2_update_final_counters()` in `trace2_thread_exit_fl()`.)
This is the only step that requires a lock.

There are also calls to those two routines in `tr2main_atexit_handler()`
to accumulate any timer/counter usage in the main thread into the
globals.

The net-net of all of this is that the global (aka final) values
of the timers and counters are always safely computed (and in the
same way) regardless of whether threads were used at any point
during the life of the process.  That is, if "main" was the only
thread, the global/final values are just the values from the main
thread.


> That was my thought as well, but these tests are specifically testing
> how it interacts with threading. The counter mechanism works in general
> without threading.
> 
> The test descriptions don't help, and should really say that they're to
> do with threading in particular, but I wanted to keep this as small as
> possible for rc[12] and the final, so I didn't fix that while-at-it.

There is large comment block above `have_timer_event()` and
`have_counter_event()` in t0211 that explained the purpose of the
test1 and test2 tests for each.  Would it help if that text were moved
down before each of the individual tests rather than where it is now?

Thanks
Jeff

  reply	other threads:[~2022-11-28 16:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <010201d9002ee2f9940nexbridge.com>
2022-11-24 21:48 ` [PATCH] trace2 tests: guard pthread test with "PTHREAD" Ævar Arnfjörð Bjarmason
2022-11-25  6:41   ` Junio C Hamano
2022-11-25  8:05     ` Ævar Arnfjörð Bjarmason
2022-11-28 16:37       ` Jeff Hostetler [this message]
2022-11-28 17:50         ` Ævar Arnfjörð Bjarmason
2022-11-30 18:41           ` Jeff Hostetler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6c725ed6-4d74-c260-98fb-dc965b4647ee@jeffhostetler.com \
    --to=git@jeffhostetler.com \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jeffhost@microsoft.com \
    --cc=randall.becker@nexbridge.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).