---------- Forwarded message ---------
From: Stefan Hajnoczi <stefa...@gmail.com>
Date: Tue, Jun 17, 2025 at 12:00 AM
Subject: Re: Some doubts regarding scripts/tracetool/backend/*.py
To: Tanish Desai <tanishdesa...@gmail.com>


On Mon, Jun 16, 2025 at 12:48 AM Tanish Desai <tanishdesa...@gmail.com>
wrote:

Please CC qemu-devel and Paolo Bonzini so that others can participate
in discussion.

> Why do we use a _no_check_trace_foo function when trace_foo ultimately
just calls it in all backends?
> Why wasn’t the logic of _no_check_trace_foo directly included inside
trace_foo during the module's design?

I found the history of nocheck using `git log -p
scripts/tracetool/format/h.py`: nocheck was originally used by the TCG
tracing feature but was removed in commit 126d4123c50a ("tracing:
excise the tcg related from tracetool").

As far as I'm aware nothing needs nocheck anymore so code could be
refactored without worrying about existing users.

> I’m asking because I’m working on unifying the two if statements: one
unconditional if (true) in trace_foo, and another conditional if
(trace_event_get_state(...)) inside _no_check_trace_foo for older backends.
Removing this redundancy could improve performance by eliminating an extra
branch instruction per trace call, along with minor memory savings.(This
was inspired by the patch of simple backend which also did somewhat similar)

"if (true)" was also left over from the TCG tracing feature removal.

Removing nocheck and "if (true)" would be nice cleanups since they are
remnants of an old feature and no longer necessary today.

I see this more as tidying up, rather than a performance optimization
opportunity. _nocheck__trace_foo() and trace_foo() are both static
inline in the same header file. The compiler can trivially optimize
them. If "if (true)" is removed and the nocheck function is no longer
generated there probably won't be any change in the machine code
because the compiler already figured that out. debuginfo should be
smaller, but that does not affect performance at runtime and most
users will not have it installed on their systems.

Stefan

Reply via email to