Re: [PATCH v2 1/1] trace2: write to directory targets
- From
- Jeff Hostetler <git@jeffhostetler.com>
- Date
- Mar 22, 2019, 14:20 UTC
- Message-ID
- <b0d5949a-1afa-fcce-646c-d33d51686a2f@jeffhostetler.com>
- In-Reply-To
- <xmqqpnqjr3g0.fsf@gitster-ct.c.googlers.com>
On 3/21/2019 11:30 PM, Junio C Hamano wrote:
Show 29 quoted lines
> Jeff Hostetler <git@jeffhostetler.com> writes:
>
>>>> + for (attempt_count = 0; attempt_count < MAX_RANDOM_ATTEMPTS; attempt_count++) {
>>>> + strbuf_reset(&final_path);
>>>> + strbuf_addbuf(&final_path, &base_path);
>>>> + strbuf_addf(&final_path, ".%d", attempt_count);
>>
>> Since the last component of the SID is already very unique and
>> we're unlikely to have collisions, maybe change the above line to:
>>
>> if (attempt_count > 0)
>> strbuf_addf(&final_path, ".%d", attempt_count);
>>
>> and in reality expect to never have files with the suffix.
>
> That's a nice property.
>
>> Unless, that is, they turned on more than one of GIT_TR2,
>> GIT_TR2_PERF, or GIT_TR2_EVENT and pointed them at the same
>> directory, but I'm not sure if I care about that edge case
>> or not.
>
> That actually makes me wonder if the auto generated filenames want
> to have a common trait (e.g. suffix) that allows the readers to tell
> from which of these environment variables the names came from. It
> would not be very useful if two files with the same sid component
> had .1 suffix for GIT_TR2 trace for one session, and the same .1
> suffix is used for GIT_TR2_PERF trace for a pair of files from
> another session.I thought about suggesting that, but didn't think it worth the bother.
> But let's not worry about it for now. If people do not want them > get mixed up and become hard to tell apart, they can always specify > different directories for different traces.
agreed. it should be very rare. the SID is the built from "<microseconds-since-the-epoch><dash><pid>" so something would have to be seriously wrong with their system to get collision from 2 different git commands.
and yes, they the advise should be to use different directories for the different streams.
Show 7 quoted lines
> >> >>>> + fd = open(final_path.buf, O_WRONLY | O_CREAT | O_EXCL, 0666); >> [...] >> >> Nice. Thanks for looking into this. >> Jeff