From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id EF0421F404 for ; Wed, 5 Sep 2018 15:01:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727664AbeIETcP (ORCPT ); Wed, 5 Sep 2018 15:32:15 -0400 Received: from siwi.pair.com ([209.68.5.199]:25789 "EHLO siwi.pair.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726046AbeIETcP (ORCPT ); Wed, 5 Sep 2018 15:32:15 -0400 Received: from siwi.pair.com (localhost [127.0.0.1]) by siwi.pair.com (Postfix) with ESMTP id A5E183F4808; Wed, 5 Sep 2018 11:01:38 -0400 (EDT) Received: from [10.160.98.162] (unknown [167.220.148.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by siwi.pair.com (Postfix) with ESMTPSA id 681253F411A; Wed, 5 Sep 2018 11:01:38 -0400 (EDT) Subject: Re: [PATCH 1/8] trace2: create new combined trace facility To: Stefan Beller , gitgitgadget@gmail.com Cc: git , Junio C Hamano , Jeff Hostetler References: <82885700379efe6d6a83629cac4d943b99b393bf.1535734192.git.gitgitgadget@gmail.com> From: Jeff Hostetler Message-ID: Date: Wed, 5 Sep 2018 11:01:37 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On 9/4/2018 6:12 PM, Stefan Beller wrote: >> Create GIT_TR2 trace-key to replace GIT_TRACE, GIT_TR2_PERFORMANCE to >> replace GIT_TRACE_PERFORMANCE, and a new trace-key GIT_TR2_EVENT to >> generate JSON data for telemetry purposes. Other structured formats >> can easily be added later using this new existing model. > > So the idea is to use the GIT_TR2 instead of GIT_TRACE and we > get the same output as well as a new form of structured logging here? > (Then GIT_TRACE could be retired, and we'd use the new API to add > more events, which are also more structured as the API allows for more > than just a string printed?) > >> Define a higher-level event API that selectively writes to all of the >> new GIT_TR2_* targets (depending on event type) without needing to call >> different trace_printf*() or trace_performance_*() routines. >> >> The API defines both fixed-field and printf-style functions. >> >> The trace2 performance tracing includes thread-specific function >> nesting and timings. > > So this only adds the new API, and we need to merge the TRACE > into the TRACE2 later? > >> +++ b/trace2.c >> @@ -0,0 +1,1592 @@ > [...] >> + >> +/***************************************************************** >> + * TODO remove this section header >> + *****************************************************************/ > > Yes, please. > >> +/* >> + * Compute a "unique" session id (SID) for the current process. All events >> + * from this process will have this label. If we were started by another >> + * git instance, use our parent's SID as a prefix and count the number of >> + * nested git processes. (This lets us track parent/child relationships >> + * even if there is an intermediate shell process.) > > How does this work with threading. From this description we can have > two threads starting new child processes and they have the same ID > (-2) Threads are not involved here. A git process computes its own unique session id. It is constructed from { [], , }. So in the following example, fetch spawned rev-list and gc. (I've stripped out fields irrelevant to this discussion.) "sid":"1536153920286494-12592", "argv":["C:\\work\\gfw\\git.exe","--exec-path=.","fetch","gh"] "sid":"1536153920286494-12592/1536153925520530-23024", "argv":["git","rev-list","--objects","--stdin", ...] "sid":"1536153920286494-12592/1536153926081533-23992", "argv":["git","gc","--auto"] So 2 child processes simultaneously spawned from 2 threads in the top-level git command, would still have unique SIDs since their PIDs are unique over the time interval of their execution. In the above example, if rev-list spawned a child git process, that child's SID would have 3 components (the prefix that it inherited plus its own time and pid): 1536153920286494-12592/1536153925520530-23024/