Received: from eggs.gnu.org ([2001:4830:134:3::10]:34621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biLfu-0004UH-BZ for qemu-devel@nongnu.org; Fri, 09 Sep 2016 09:16:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1biLfo-0001Ts-Bk for qemu-devel@nongnu.org; Fri, 09 Sep 2016 09:16:58 -0400 Received: from roura.ac.upc.es ([147.83.33.10]:59557) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1biLfo-0001TG-0Y for qemu-devel@nongnu.org; Fri, 09 Sep 2016 09:16:52 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <1470756748-18933-1-git-send-email-berrange@redhat.com> <87vay6ed9t.fsf@fimbulvetr.bsc.es> <20160908134305.GL30602@redhat.com> <87y431bai0.fsf@fimbulvetr.bsc.es> <20160909120838.GJ25802@redhat.com> Date: Fri, 09 Sep 2016 15:16:50 +0200 In-Reply-To: <20160909120838.GJ25802@redhat.com> (Daniel P. Berrange's message of "Fri, 9 Sep 2016 13:08:38 +0100") Message-ID: <87bmzxb4cd.fsf@fimbulvetr.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH for-2.8 v1 00/60] Modular build of trace event files List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: qemu-devel@nongnu.org, Stefan Hajnoczi Daniel P Berrange writes: > On Fri, Sep 09, 2016 at 01:03:51PM +0200, Llu=C3=ADs Vilanova wrote: >> Daniel P Berrange writes: >>=20 >> > On Thu, Sep 08, 2016 at 03:23:26PM +0200, Llu=C3=ADs Vilanova wrote: >> >> Daniel P Berrange writes: >> >>=20 >> >> > I previously split the global trace-events file up into one file >> >> > per-subdirectory to avoid merge conflict hell. >> >> [...] >> >>=20 >> >> Sorry, I could not find the message where the infrastructure is modif= ied to >> >> provide this. But I think there's a more efficient way to provide mod= ular >> >> auto-generated tracing code without the hierarchical indexing you pro= posed. >>=20 >> > [snip] >>=20 >> >> struct TraceEvent ___trace_events[] =3D { >> >> { >> >> .name =3D "eventname", >> >> .sstate =3D 1, >> >> .dstate =3D ___trace_eventname_dstate; >> >> } >> >> } >> >>=20 >> >> TraceEvent *TRACE_EVENTNAME =3D &___trace_events[...]; >>=20 >> > Life would be simpler if we had the 'bool dstate' as part of the >> > TraceEvent struct, but doing so would essentially be reverting this >> > previous change: >>=20 >> > commit 585ec7273e6fdab902b2128bc6c2a8136aafef04 >> > Author: Paolo Bonzini >> > Date: Wed Oct 28 07:06:27 2015 +0100 >>=20 >> > trace: track enabled events in a separate array >>=20 >> > This is more cache friendly on the fast path, where we already have >> > the event id available. >>=20 >> > I asked Paolo about this previously and he indicated it was a notable >> > performance improvement, so we can't put dstate back into the TraceEve= nt >> > struct :-( >>=20 >> Sorry, there was a typo in my example code that led to this misunderstan= ding. >>=20 >> I meant this for the global auto-generated .c: >>=20 >> struct TraceEvent { >> /* ... */ >> bool *dstate; >> }; >>=20 >> bool ___TRACE_EVENTNAME_DSTATE; >>=20 >> struct TraceEvent ___trace_events[] =3D { >> { >> .name =3D "eventname", >> .sstate =3D 1, >> .dstate =3D &___TRACE_EVENTNAME_DSTATE; >> } >> } >>=20 >> TraceEvent *TRACE_EVENTNAME =3D &___trace_events[...]; >>=20 >>=20 >> If you look at the modified macro I pasted for "trace/control-internal.h= ": >>=20 >>=20 >> #define trace_event_get_state_dynamic_by_id(id) \ >> (unlikely(trace_events_enabled_count) && \ >> (___ ## id ## _DSTATE)) >>=20 >> We're retaining the fast-path performance of the seggregated boolean dst= ate >> array, while the event descriptor contains a pointer to the per-event ds= tate >> global boolean variable in case you want to get/set the dstate based on = an event >> pointer. > The various _DSTATE variables are still arbitrarily scattered in > memory, as opposed to in a contiguous cache friendly array, which > is one of the goals of Paolo's original change. > That said, I'm unclear on how much of the performance win from > Paolo's change came from eliminating the struct field de-reference, > vs having the contiguous array. I'm guessing most of the win is > from the former, the latter only being important if we hit multiple > related tracepoints on close succession. The latter can also be achieved by packing them all together in a single section, but I don't know if that's acceptable within portable QEMU code. F= or example: bool ___TRACE_EVENTNAME_DSTATE __attribute__((section("dstate_array"))) Cheers, Lluis