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

improve disk queue performance by coalescing writes #31935

Merged
merged 1 commit into from
Jun 16, 2022

Conversation

leehinman
Copy link
Contributor

Improves speed and lowers allocations

What does this PR do?

Improves speed and lowers allocations in disk queue by coalescing writes.

Why is it important?

lowers performance cost of using disk queue.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
    - [ ] I have made corresponding changes to the documentation
    - [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

How to test this PR locally

Tested with libbeat/publisher/queue/diskqueue/benchmark_test.go

before change
go test -bench=. -benchtime 1x -count 10 -timeout 120m -benchmem > baseline.txt

after change
go test -bench=. -benchtime 1x -count 10 -timeout 120m -benchmem > gather_w.txt

benchstat baseline.txt gather_w.txt
name       old time/op    new time/op    delta
1M_10-16      38.7s ± 2%     21.8s ± 0%  -43.58%  (p=0.000 n=10+7)
1M_100-16     38.7s ± 1%     21.8s ± 1%  -43.74%  (p=0.000 n=10+10)
1M_1k-16      38.6s ± 1%     21.9s ± 1%  -43.36%  (p=0.000 n=10+10)
1M_10k-16     38.7s ± 2%     21.7s ± 0%  -43.78%  (p=0.000 n=10+10)

name       old alloc/op   new alloc/op   delta
1M_10-16     3.47GB ± 0%    3.43GB ± 0%   -1.16%  (p=0.000 n=8+10)
1M_100-16    3.47GB ± 0%    3.43GB ± 0%   -1.17%  (p=0.000 n=10+8)
1M_1k-16     3.47GB ± 0%    3.43GB ± 0%   -1.18%  (p=0.000 n=10+8)
1M_10k-16    3.47GB ± 0%    3.43GB ± 0%   -1.18%  (p=0.000 n=10+10)

name       old allocs/op  new allocs/op  delta
1M_10-16      43.4M ± 0%     40.6M ± 0%   -6.32%  (p=0.000 n=8+10)
1M_100-16     43.4M ± 0%     40.6M ± 0%   -6.42%  (p=0.000 n=10+9)
1M_1k-16      43.4M ± 0%     40.6M ± 0%   -6.49%  (p=0.000 n=10+10)
1M_10k-16     43.4M ± 0%     40.6M ± 0%   -6.49%  (p=0.000 n=10+10)

Related issues

@leehinman leehinman added enhancement Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team labels Jun 15, 2022
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Jun 15, 2022
@leehinman leehinman force-pushed the disk_queue_perf branch 2 times, most recently from fb292f3 to 930da1e Compare June 15, 2022 00:56
@elasticmachine
Copy link
Collaborator

elasticmachine commented Jun 15, 2022

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@leehinman leehinman marked this pull request as ready for review June 15, 2022 17:04
@leehinman leehinman requested a review from a team as a code owner June 15, 2022 17:04
@leehinman leehinman requested review from cmacknz and faec and removed request for a team June 15, 2022 17:04
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@leehinman
Copy link
Contributor Author

/test

@cmacknz
Copy link
Member

cmacknz commented Jun 15, 2022

LGTM, I'll let @faec do the approving here. The test failure is fixed by #31943

@leehinman leehinman mentioned this pull request Jun 15, 2022
5 tasks
Tested with libbeat/publisher/queue/diskqueue/benchmark_test.go

before change
go test -bench=. -benchtime 1x -count 10 -timeout 120m -benchmem > baseline.txt

after change
go test -bench=. -benchtime 1x -count 10 -timeout 120m -benchmem > gather_w.txt

benchstat baseline.txt gather_w.txt
name       old time/op    new time/op    delta
1M_10-16      38.7s ± 2%     21.8s ± 0%  -43.58%  (p=0.000 n=10+7)
1M_100-16     38.7s ± 1%     21.8s ± 1%  -43.74%  (p=0.000 n=10+10)
1M_1k-16      38.6s ± 1%     21.9s ± 1%  -43.36%  (p=0.000 n=10+10)
1M_10k-16     38.7s ± 2%     21.7s ± 0%  -43.78%  (p=0.000 n=10+10)

name       old alloc/op   new alloc/op   delta
1M_10-16     3.47GB ± 0%    3.43GB ± 0%   -1.16%  (p=0.000 n=8+10)
1M_100-16    3.47GB ± 0%    3.43GB ± 0%   -1.17%  (p=0.000 n=10+8)
1M_1k-16     3.47GB ± 0%    3.43GB ± 0%   -1.18%  (p=0.000 n=10+8)
1M_10k-16    3.47GB ± 0%    3.43GB ± 0%   -1.18%  (p=0.000 n=10+10)

name       old allocs/op  new allocs/op  delta
1M_10-16      43.4M ± 0%     40.6M ± 0%   -6.32%  (p=0.000 n=8+10)
1M_100-16     43.4M ± 0%     40.6M ± 0%   -6.42%  (p=0.000 n=10+9)
1M_1k-16      43.4M ± 0%     40.6M ± 0%   -6.49%  (p=0.000 n=10+10)
1M_10k-16     43.4M ± 0%     40.6M ± 0%   -6.49%  (p=0.000 n=10+10)

Improves speed and lowers allocations
Copy link
Contributor

@faec faec left a comment

Choose a reason for hiding this comment

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

looks good, thank you!

@leehinman leehinman merged commit 330f031 into elastic:main Jun 16, 2022
@leehinman leehinman mentioned this pull request Jun 16, 2022
5 tasks
chrisberkhout pushed a commit that referenced this pull request Jun 1, 2023
Tested with libbeat/publisher/queue/diskqueue/benchmark_test.go

before change
go test -bench=. -benchtime 1x -count 10 -timeout 120m -benchmem > baseline.txt

after change
go test -bench=. -benchtime 1x -count 10 -timeout 120m -benchmem > gather_w.txt

benchstat baseline.txt gather_w.txt
name       old time/op    new time/op    delta
1M_10-16      38.7s ± 2%     21.8s ± 0%  -43.58%  (p=0.000 n=10+7)
1M_100-16     38.7s ± 1%     21.8s ± 1%  -43.74%  (p=0.000 n=10+10)
1M_1k-16      38.6s ± 1%     21.9s ± 1%  -43.36%  (p=0.000 n=10+10)
1M_10k-16     38.7s ± 2%     21.7s ± 0%  -43.78%  (p=0.000 n=10+10)

name       old alloc/op   new alloc/op   delta
1M_10-16     3.47GB ± 0%    3.43GB ± 0%   -1.16%  (p=0.000 n=8+10)
1M_100-16    3.47GB ± 0%    3.43GB ± 0%   -1.17%  (p=0.000 n=10+8)
1M_1k-16     3.47GB ± 0%    3.43GB ± 0%   -1.18%  (p=0.000 n=10+8)
1M_10k-16    3.47GB ± 0%    3.43GB ± 0%   -1.18%  (p=0.000 n=10+10)

name       old allocs/op  new allocs/op  delta
1M_10-16      43.4M ± 0%     40.6M ± 0%   -6.32%  (p=0.000 n=8+10)
1M_100-16     43.4M ± 0%     40.6M ± 0%   -6.42%  (p=0.000 n=10+9)
1M_1k-16      43.4M ± 0%     40.6M ± 0%   -6.49%  (p=0.000 n=10+10)
1M_10k-16     43.4M ± 0%     40.6M ± 0%   -6.49%  (p=0.000 n=10+10)

Improves speed and lowers allocations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants