-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tracing in etcd server to range, put and compact requests #11179
Conversation
Thanks @YoyinZyc. For completeness, could you also share the benchmark result? |
@YoyinZyc Can you provide example tracing log outputs with new changes? |
@gyuho The example of new tracing log outputs were updated in my first comment. |
Can you also benchmark with short range requests to make sure there is no noticeable impact on throughput? |
@jingyih The benchmark result for short range requests were updated in my benchmark comment above. |
Potentially, the step "Range keys from in-memory index tree" could also be relatively expensive if client is listing a lot of keys in pages. (e.g. listing 1 million events in 500-sized pages). |
Yeah, let's try to merge and release in v3.4.2 next week. I will take another look next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor clean up, overall looks great!
@YoyinZyc Can we squash commits? We need cherry-pick this to 3.4, and squashing commits would make it easier.
do we have plan to add tracing to other operations? |
steps:range from the in-memory index tree; range from boltdb. etcdserver: add tracing steps: agreement among raft nodes before linerized reading; authentication; filter and sort kv pairs; assemble the response.
to reduce log volume.
Giving that K8s uses Range and Txn heavily, I think it makes sense to also add tracing for Txn. |
I guess we should add tracing to all operations to make it more consistent inside etcd. |
I think it makes sense to add tracing to kv operations. I will put them into another pr. Btw, I opened an issue #11191 on txn tracing. |
If we would like to cherrypick it to 3.4 release (which in my opinion would be highly valuable), I think we should try to do everything we want in a single PR to avoid cherrypicking a number of PRs. |
@YoyinZyc Let's trace |
mvcc: add put request steps; add trace to KV.Write() as input parameter.
Added trace to
Compaction:
|
Put(txn mvcc.TxnWrite, p *pb.PutRequest) (*pb.PutResponse, error) | ||
Range(txn mvcc.TxnRead, r *pb.RangeRequest) (*pb.RangeResponse, error) | ||
Put(txn mvcc.TxnWrite, p *pb.PutRequest) (*pb.PutResponse, *traceutil.Trace, error) | ||
Range(ctx context.Context, txn mvcc.TxnRead, r *pb.RangeRequest) (*pb.RangeResponse, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make method signatures consistent for Put
and Compaction
?
For me, passing context.Context
seems cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is hard to make it consistent with range. For put and compaction request, they need to make raft request first. When etcdserver receives the signal from raft, it will trigger the following apply process.
Line 113 in c2f2309
resp, err := s.raftRequest(ctx, pb.InternalRaftRequest{Put: r}) |
Line 1036 in c2f2309
case ap := <-s.r.apply(): |
I don't think it is a good way to change too many apis inside raft. Therefore, the way I use now is to trace in
apply
then measure the raft request time by calculate the time difference between apply start time
and req start time
Do you think it makes sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, makes sense.
Btw, we don't really need ctx
parameter to Range
unless we want to trace more in auth applier? Can we just create trace object at the top level of Range
method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, wait. It has to be passed from v3 server. So, nvm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @YoyinZyc! Overall looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added one comment. LGTM otherwise.
… applierV3.Compaction() mvcc: trace compaction request; add input parameter 'trace' to KV.Compact()
LGTM |
@YoyinZyc Please highlight this in our CHANGELOG. And can you work on backporting this to v3.4 branch? |
CHANGELOG: update #11179 in changelog-3.4
…79-origin-release-3.4 Automated cherry pick of #11179
Fix issue #11166.
This pr creates a standalone trace pkg for record the lifecycle of the request in etcd server. We only enable tracing for range request in this pr. Please refer to issue #11166 for the motivation of it.
Here is the example output of range request with no threshold:
To avoid log flood, we choose to log out only when exceed the threshold. In this pr, we set the default threshold to 100ms which is as same as
warnApplyDuration
. Here is the example output with threshold:Some steps disappear because the duration of these steps are smaller than
stepThreshold
which isthreshold / (len(steps)+1)
.As for performance, there is no obvious difference with and without trace when I run the benchmark with a range request of key count 100000.