Skip to content

#12440 Add benchmark for LogPublisher - #12445

Merged
adiroiban merged 9 commits into
twisted:trunkfrom
allrob23:bench-log
May 2, 2025
Merged

adiroiban merged 9 commits into
twisted:trunkfrom
allrob23:bench-log

Conversation

@allrob23

@allrob23 allrob23 commented Apr 30, 2025 •

Copy link
Copy Markdown
Contributor

Scope and purpose

This benchmark measures the performance of the LogPublisher when dispatching events to multiple observers and when adding/removing observers. It evaluates the cost of maintaining an ordered set of unique observers under different loads.

This benchmark was added as part of the work in PR #12440.

@codspeed

codspeed Bot commented Apr 30, 2025 •

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #12445 will degrade performances by 3.25%

Comparing allrob23:bench-log (9d96bfa) with trunk (e09d042)

Summary

❌ 1 regressions
✅ 33 untouched benchmarks
🆕 2 new benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
❌ test_deferred_await 3.9 ms 4 ms -3.25%
🆕 test_log_publisher_add_remove N/A 137.2 ms N/A
🆕 test_log_publisher_call_dispatch N/A 1.3 ms N/A

@allrob23

Copy link
Copy Markdown
Contributor Author

please review

@glyph

glyph commented Apr 30, 2025

Copy link
Copy Markdown
Member

Static checks are failing, can you get required statuses to pass before submitting please?

@adiroiban adiroiban changed the title test: add benchmark for LogPublisher #12440 Add benchmark for LogPublisher Apr 30, 2025
@adiroiban

adiroiban commented Apr 30, 2025 •

Copy link
Copy Markdown
Member

Thanks for the tests. I created a newsfragment as a placeholder to support the PR #12440

and make the test file a .py file so that it will be executed by our test infra

it looks like the benchmark test environment is kind of flaky today... I triggered a re-run for the benchmark tests

Comment thread benchmarks/test_log_publisher.py Outdated
self.last_event = event


@pytest.mark.parametrize("num_observers", [100, 500, 1000])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just asking. Is there a any benefit in running with differet sizes ?

I guess that we only want to run the benchmark for as large of a set as possible

this should reduce run variations / flaky tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, I updated the code.

Comment thread benchmarks/test_log_publisher.py Resolved

@adiroiban adiroiban left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Many thanks for the PR.

I don't have much experience with writing benchmark tests...but I think that this is a start

The failure for test_deferred_await is not related to this PR

I left a few comments.

I think that we can merge this, and if needed we can make more changes as part of #12440

Thanks again

@adiroiban
adiroiban requested a review from a team April 30, 2025 07:06

@twm twm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks reasonable to me. Thank you for the contribution, and I look forward to the next one!

@@ -0,0 +1 @@
Add benchmark test to support future PR.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If this weren't a .misc it should mention that it's a benchmark of LogPublisher. I think .misc is fine in this case, though.

@adiroiban
adiroiban merged commit f0027bf into twisted:trunk May 2, 2025
@adiroiban

Copy link
Copy Markdown
Member

Thanks @allrob23 for the PR and thanks @twm for the review.

I have merged this. I will update the follow PR and we should be able to observe the performance impact of that PR

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.

5 participants