Skip to content
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

enhance: improve log encoding performance on proxy nodes #36123

Merged
merged 4 commits into from
Sep 11, 2024

Conversation

tedxu
Copy link
Contributor

@tedxu tedxu commented Sep 9, 2024

See #36122

This PR is designed to enhance log performance through two improvements:

  1. Optimize JSON encoding by switching JSON serializer to json-iterator.
  2. Adding support of lazy initialization WithLazy.

@sre-ci-robot sre-ci-robot added size/L Denotes a PR that changes 100-499 lines. area/dependency Pull requests that update a dependency file labels Sep 9, 2024
@mergify mergify bot added dco-passed DCO check passed. kind/enhancement Issues or changes related to enhancement labels Sep 9, 2024
@tedxu
Copy link
Contributor Author

tedxu commented Sep 9, 2024

Benchmark results using default JSON library:

goos: darwin
goarch: arm64
pkg: github.com/milvus-io/milvus/pkg/log
BenchmarkZapReflect-8          92625             11556 ns/op            2718 B/op         13 allocs/op

Results of using json-iterator and WithLazy

goos: darwin
goarch: arm64
pkg: github.com/milvus-io/milvus/pkg/log
BenchmarkZapReflect-8    	  135888	      8713 ns/op	    3226 B/op	      15 allocs/op
BenchmarkZapWithLazy-8   	 1278234	       909.8 ns/op	     496 B/op	       9 allocs/op

@mergify mergify bot added the ci-passed label Sep 9, 2024
Copy link

codecov bot commented Sep 9, 2024

Codecov Report

Attention: Patch coverage is 85.71429% with 5 lines in your changes missing coverage. Please review.

Project coverage is 84.87%. Comparing base (7b21032) to head (333e2ef).
Report is 58 commits behind head on master.

Files with missing lines Patch % Lines
pkg/log/lazy_with.go 82.60% 4 Missing ⚠️
internal/proxy/task_search.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #36123      +/-   ##
==========================================
+ Coverage   81.59%   84.87%   +3.27%     
==========================================
  Files        1266      990     -276     
  Lines      150648   126343   -24305     
==========================================
- Hits       122924   107229   -15695     
+ Misses      22853    14202    -8651     
- Partials     4871     4912      +41     
Files with missing lines Coverage Δ
internal/datanode/compaction/merge_sort.go 72.83% <ø> (ø)
internal/datanode/compaction/segment_writer.go 79.74% <ø> (-0.72%) ⬇️
internal/proxy/impl.go 85.87% <100.00%> (-0.03%) ⬇️
pkg/log/global.go 100.00% <100.00%> (ø)
pkg/log/mlogger.go 100.00% <100.00%> (ø)
pkg/log/zap_text_encoder.go 85.41% <100.00%> (ø)
internal/proxy/task_search.go 77.41% <0.00%> (+0.46%) ⬆️
pkg/log/lazy_with.go 82.60% <82.60%> (ø)

... and 359 files with indirect coverage changes

@tedxu
Copy link
Contributor Author

tedxu commented Sep 10, 2024

I'm directing all With invocations to WithLazy since there is no cost for the later one. See benchmark results:

BenchmarkWithLazyLog-8             10000            154245 ns/op            2606 B/op         19 allocs/op
BenchmarkWithLog-8                     10000            144891 ns/op            5332 B/op         25 allocs/op

@mergify mergify bot removed the ci-passed label Sep 10, 2024
Signed-off-by: Ted Xu <[email protected]>
@mergify mergify bot added the ci-passed label Sep 10, 2024
Copy link
Contributor

@congqixia congqixia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@sre-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: congqixia, tedxu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sre-ci-robot sre-ci-robot merged commit e7ea1d7 into milvus-io:master Sep 11, 2024
16 checks passed
chyezh pushed a commit to chyezh/milvus that referenced this pull request Sep 11, 2024
…6123)

See milvus-io#36122

This PR is designed to enhance log performance through two improvements:

1. Optimize JSON encoding by switching JSON serializer to
`json-iterator`.
2. Adding support of lazy initialization `WithLazy`.

---------

Signed-off-by: Ted Xu <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/dependency Pull requests that update a dependency file ci-passed dco-passed DCO check passed. kind/enhancement Issues or changes related to enhancement lgtm size/L Denotes a PR that changes 100-499 lines.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants