h2 icon indicating copy to clipboard operation
h2 copied to clipboard

Make tracing an optional feature

Open seanmonstar opened this issue 1 year ago • 4 comments

Make tracing available as a Cargo feature, probably default off.

seanmonstar avatar Sep 11 '23 19:09 seanmonstar

While test integrating tonic into TiKV to replace grpc-rs, I found that tonic's performance is not as good as grpc-rs as it consumes more cpu. And from the profile, I saw that a lot of cpu time is cost by the tracing logic in h2. In some workloads, the qps with tonic can be 15% lower than grpc-rs. Here is a cpu profiling snapshot:

image

After patching tonic with a h2 package with all tracing code removed, tonic's performance is slightly better than gprc-rs in almost all workload without any further optimization.

glorv avatar Jun 20 '24 02:06 glorv

There's something about this that surprises me. Namely, should tracing really incur a 15% overhead if the tracing level is low? That seems shocking. @glorv any interest in providing repro steps or raw profiles?

ajwerner avatar Aug 06 '24 18:08 ajwerner

There's something about this that surprises me. Namely, should tracing really incur a 15% overhead if the tracing level is low? That seems shocking. @glorv any interest in providing repro steps or raw profiles?

@ajwerner It's an attempt to replace grpc-rs with tonic for tikv. The workload is sysbench 's oltp_write_only that is a CPU heavy workload with high write concurrency(256 in my benchmark). So any part consumes more CPU will result with a performance regression.

Here are 2 profiles with the same workload, the 2nd is patched with all tracing code removed.

profile.zip (Because github doesn't allow to paste raw .proto file, I put the two profile samples in this zip).

glorv avatar Aug 07 '24 09:08 glorv