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

use cgroup_ips map to improve mb_connect performance #227

Merged
merged 17 commits into from
Oct 20, 2022

Conversation

kebe7jun
Copy link
Member

@kebe7jun kebe7jun commented Oct 14, 2022

bpf_sk_lookup_tcp may cost 50-150ns per ops, It is more expensive.

Without cache:

 kebe@Kebe-DaoCloud-PC  ~/workspace/mebpf   main ±  sudo go test -bench .
goos: linux
goarch: amd64
pkg: github.com/merbridge/merbridge
cpu: AMD Ryzen 9 3900 12-Core Processor             
BenchmarkConnect/eBPF-24                1000000000               0.4532 ns/op
BenchmarkConnect/eBPF/mb_sock_connect        108              3203 ns/op
BenchmarkSockops/eBPF-24                1000000000               0.4327 ns/op
BenchmarkSockops/eBPF/mb_sockops             954               689.2 ns/op
PASS
ok      github.com/merbridge/merbridge  20.530s

After cached:

 kebe@Kebe-DaoCloud-PC  ~/workspace/mebpf   main ±  sudo go test -bench .
goos: linux
goarch: amd64
pkg: github.com/merbridge/merbridge
cpu: AMD Ryzen 9 3900 12-Core Processor             
BenchmarkConnect/eBPF-24                1000000000               0.4539 ns/op
BenchmarkConnect/eBPF/mb_sock_connect        107              2475 ns/op
BenchmarkSockops/eBPF-24                1000000000               0.4545 ns/op
BenchmarkSockops/eBPF/mb_sockops             963               672.1 ns/op
PASS
ok      github.com/merbridge/merbridge  21.205s

The optimization results in a 20% performance improvement for connect programs.

@kebe7jun kebe7jun requested a review from a team as a code owner October 14, 2022 01:56
@mergify
Copy link

mergify bot commented Oct 14, 2022

Welcome to the Merbridge OpenSource Community!👏

We're delighted to have you onboard 💘

@kebe7jun kebe7jun requested a review from a team as a code owner October 14, 2022 03:20
@codecov-commenter
Copy link

codecov-commenter commented Oct 14, 2022

Codecov Report

Merging #227 (f2fc82d) into main (9ed9eac) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #227   +/-   ##
=======================================
  Coverage   40.33%   40.33%           
=======================================
  Files           7        7           
  Lines         419      419           
=======================================
  Hits          169      169           
  Misses        236      236           
  Partials       14       14           
Flag Coverage Δ
unittests 40.33% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@dddddai dddddai left a comment

Choose a reason for hiding this comment

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

Is it possible to optimize is_port_listen_current_ns as well?

@kebe7jun
Copy link
Member Author

Is it possible to optimize is_port_listen_current_ns as well?

Great, I am trying to optimize these calls in a unified way.

@kebe7jun kebe7jun marked this pull request as draft October 14, 2022 06:46
@kebe7jun kebe7jun force-pushed the improve-connect-performance branch 2 times, most recently from ef38107 to ef9c205 Compare October 17, 2022 05:50
@kebe7jun kebe7jun force-pushed the improve-connect-performance branch 3 times, most recently from 36c1b3f to a714733 Compare October 18, 2022 03:46
@kebe7jun kebe7jun marked this pull request as ready for review October 18, 2022 04:41
@mergify
Copy link

mergify bot commented Oct 18, 2022

Welcome to the Merbridge OpenSource Community!👏

We're delighted to have you onboard 💘

@kebe7jun
Copy link
Member Author

@dddddai This is ready to review.

Copy link
Member

@dddddai dddddai left a comment

Choose a reason for hiding this comment

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

For ipv6 we can follow up

bpf/headers/cgroup.h Outdated Show resolved Hide resolved
bpf/headers/cgroup.h Outdated Show resolved Hide resolved
bpf/headers/cgroup.h Outdated Show resolved Hide resolved
@kebe7jun
Copy link
Member Author

@Xunzhuo PTAL.

Copy link
Member

@Xunzhuo Xunzhuo left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for working on this.

@Xunzhuo
Copy link
Member

Xunzhuo commented Oct 20, 2022

@Mergifyio refresh

@mergify
Copy link

mergify bot commented Oct 20, 2022

refresh

✅ Pull request refreshed

@kebe7jun kebe7jun merged commit 4996145 into merbridge:main Oct 20, 2022
@kebe7jun kebe7jun deleted the improve-connect-performance branch October 20, 2022 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants