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

[Don't merge] Stress test for CircularBuffer #1086

Closed
wants to merge 3 commits into from

Conversation

reyang
Copy link
Member

@reyang reyang commented Aug 15, 2020

This is a stress test tool for the Circular Buffer [#1085].

dotnet run --configuration=Release

The test is writing to a circular buffer from N parallel tasks, where N is the number of logical processors.
Each writer is inserting monotonic numbers to the circular buffer, starting from 1 to bound inclusively ([1, bound]). If the buffer is full, the writer will retry until success.
A single task is reading from the circular buffer, calculating the total sum of the numbers.
Near real-time statistics are displayed in the console window title.

When all the writer/reader tasks finished, the result value should be 0, otherwise it indicates a bug in the implementation.

Test buffer size can be changed to simulate different situation.

For example, changing the buffer size to a smaller number would simulate the insertion failure/retry case:

var buffer = new CircularBuffer<Item>(10000);

image

@reyang reyang requested a review from a team August 15, 2020 21:31
@reyang reyang force-pushed the reyang/buffer-stress branch 2 times, most recently from 2e57404 to c5340b1 Compare August 16, 2020 01:59
@reyang
Copy link
Member Author

reyang commented Aug 16, 2020

Need help from folks to stress it on different architecture / platforms with different combinations of settings.

Base automatically changed from reyang/buffer to master August 16, 2020 05:13
@reyang reyang force-pushed the reyang/buffer-stress branch from da24f10 to f0978fa Compare August 16, 2020 19:48
@reyang reyang closed this Aug 16, 2020
@reyang reyang deleted the reyang/buffer-stress branch August 16, 2020 19:54
@reyang reyang mentioned this pull request Aug 16, 2020
2 tasks
@ThomsonTan
Copy link
Contributor

ThomsonTan commented Aug 16, 2020

Need help from folks to stress it on different architecture / platforms with different combinations of settings.

Ran the stress on x64 (12 cores 3.6GHz, Intel W-2133) and Surface Pro X (3.0GHz 8 cores ARM64) with .NET core 5.0 preview for ARM64, stress passed for more than 10 runs on each platform.

BTW: the race condition ratio of below line is ~1% (means failed to add 1 event among 100 events) on X64 and ~7% on ARM64.
Interlocked.CompareExchange(ref this.head, headSnapshot + 1, headSnapshot) == headSnapshot

@reyang
Copy link
Member Author

reyang commented Aug 16, 2020

Ran the stress on x64 (12 cores 3.6GHz, Intel W-2133) and Surface Pro X (3.0GHz 8 cores ARM64) with .NET core 5.0 preview for ARM64, stress passed for more than 10 runs on each platform.

Why would you have so many powerful 💪 machines? 🤣

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants