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

Fix NIOAsyncChannel allocation benchmarks #2622

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

FranzBusch
Copy link
Member

@FranzBusch FranzBusch commented Jan 9, 2024

Motivation

We had to disable the benchmarks since they regressed without us noticing and they appear to be flaky.

Modification

This PR fixes the allocation regression and tries to re-enable them.

try await self._storage.yield(contentsOf: CollectionOfOne(element))
try await self._storage.yield(element: element)
Copy link
Member Author

Choose a reason for hiding this comment

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

The fix here is quite simple. The problem was that we lost the fast path for single element writes in some refactoring. This PR duplicates the write path and specialises one of them for single element writes to call the optimised delegate method of the writer.

@FranzBusch FranzBusch force-pushed the fb-async-channel-benchmark-fix branch from 1abaab4 to 5ff86ef Compare January 9, 2024 11:39
configuration: .init(
metrics: defaultMetrics,
timeUnits: .milliseconds,
scalingFactor: .mega,
Copy link
Contributor

Choose a reason for hiding this comment

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

If you update to Benchmark 1.22.0 you can now add some slack to the p90 check for malloc counts, this should do the trick (allowing for a +-100 mallocs);

Suggested change
scalingFactor: .mega,
scalingFactor: .mega,
thresholds: [.mallocCountTotal : .init(absolute: [.p90 : 100])],

@FranzBusch FranzBusch force-pushed the fb-async-channel-benchmark-fix branch 2 times, most recently from 3312324 to ad67033 Compare January 11, 2024 14:23
@FranzBusch FranzBusch force-pushed the fb-async-channel-benchmark-fix branch from ad67033 to 9775ef7 Compare January 11, 2024 15:33
# Motivation
We had to disable the benchmarks since they regressed without us noticing and they appear to be flaky.

# Modification
This PR fixes the allocation regression and tries to re-enable them.
@FranzBusch FranzBusch force-pushed the fb-async-channel-benchmark-fix branch from 9775ef7 to 02efe9d Compare January 12, 2024 13:32
@FranzBusch FranzBusch marked this pull request as ready for review January 12, 2024 14:23
@FranzBusch FranzBusch merged commit 826fce4 into apple:main Jan 12, 2024
10 checks passed
@FranzBusch FranzBusch deleted the fb-async-channel-benchmark-fix branch January 12, 2024 14:23
@glbrntt glbrntt added the needs-no-version-bump For PRs that when merged do not need a bump in version number. label Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-no-version-bump For PRs that when merged do not need a bump in version number.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants