Re: [PATCH 2/9] trace2: convert tr2tls_thread_ctx.thread_name from strbuf to char*
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 22, 2021, 19:57 UTC
- Message-ID
- <xmqq8rwcjttq.fsf@gitster.g>
- In-Reply-To
- <ea4eb7f2-863f-2439-d175-cd4e97ad63a6@jeffhostetler.com>
Jeff Hostetler <git@jeffhostetler.com> writes:
Show 5 quoted lines
> I'll convert it to a flex-array at the bottom of the CTX structure > and then defer the truncation to the _perf target (which only does > that to keep the columns lined up). > > That will simplify things considerably.
I am not sure if the complexity of flex-array is worth it.
You have been storing an up-to-24-byte human readable name by embedding a strbuf that has two size_t plus a pointer (i.e. 24-bytes even on Windows), and the posted patch changes it to a pointer plus a on-heap allocation with malloc() overhead.
An embedded fixed-size thread_name[TR2_MAX_THREAD_NAME+1] member may be the simplest thing to do, I suspect.