-
Notifications
You must be signed in to change notification settings - Fork 1.4k
20251023 steady state add latency #2003
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
Open
mcgrof
wants to merge
6
commits into
axboe:master
Choose a base branch
from
mcgrof:20251023-steady-state-add-latency
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ceadd92
configure: conditionally add gnutls for libnfs >= 6.0.0
mcgrof 936ef18
fio: refactor steady state validation check
mcgrof caf3902
fio: refactor duplicate code in steadystate_*_mean functions
mcgrof e6ef1c1
fio: add latency steady state detection
mcgrof 7f55d2d
fio: add mock test framework for isolated unit testing
mcgrof 950daee
mock-tests: assess per second latency recovery
vincentkfu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # Example FIO job file demonstrating latency steady state detection | ||
| # This example shows how to use FIO's latency steady state detection | ||
| # to automatically terminate workloads when latency stabilizes | ||
| # | ||
| # Based on SNIA SSD Performance Test Specification requirements: | ||
| # - Steady state is achieved when latency measurements don't change more than | ||
| # 20% for 5 measurement windows and remain within 5% of a line with 10% slope | ||
| # - This example uses more conservative 5% deviation threshold for demonstration | ||
|
|
||
| [global] | ||
| # Basic I/O parameters | ||
| ioengine=libaio | ||
| iodepth=32 | ||
| bs=4k | ||
| direct=1 | ||
| rw=randread | ||
| numjobs=1 | ||
| time_based=1 | ||
| runtime=3600 # Max runtime: 1 hour (will terminate early if steady state reached) | ||
|
|
||
| # Steady state detection parameters | ||
| steadystate=lat:5% # Stop when latency mean deviation < 5% of average | ||
| steadystate_duration=300 # Use 5-minute rolling window for measurements | ||
| steadystate_ramp_time=60 # Wait 1 minute before starting measurements | ||
| steadystate_check_interval=10 # Take measurements every 10 seconds | ||
|
|
||
| # Output options | ||
| write_lat_log=lat_steadystate | ||
| log_avg_msec=10000 # Log average latency every 10 seconds | ||
|
|
||
| [latency_steady_test] | ||
| filename=/dev/nvme3n1 | ||
| size=10G | ||
|
|
||
| # Alternative steady state configurations (uncomment to try): | ||
|
|
||
| # Use slope-based detection instead of deviation: | ||
| # steadystate=lat_slope:0.1% | ||
|
|
||
| # More aggressive detection (faster convergence): | ||
| # steadystate=lat:2% | ||
| # steadystate_duration=120 # 2-minute window | ||
| # steadystate_check_interval=5 # Check every 5 seconds | ||
|
|
||
| # More conservative detection (slower convergence): | ||
| # steadystate=lat:10% | ||
| # steadystate_duration=600 # 10-minute window |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| # Makefile for FIO mock tests | ||
| # | ||
| # These tests validate specific algorithmic improvements and edge cases | ||
| # using isolated mock implementations. | ||
|
|
||
| CC ?= gcc | ||
| CFLAGS = -Wall -Wextra -O2 -g -I. -I.. -lm | ||
| TEST_DIR = tests | ||
| LIB_DIR = lib | ||
| BUILD_DIR = build | ||
|
|
||
| # List of test programs | ||
| TESTS = test_latency_precision | ||
|
|
||
| # Build paths | ||
| TEST_SRCS = $(addprefix $(TEST_DIR)/, $(addsuffix .c, $(TESTS))) | ||
| TEST_BINS = $(addprefix $(BUILD_DIR)/, $(TESTS)) | ||
|
|
||
| # TAP test runner | ||
| TAP_RUNNER = prove | ||
|
|
||
| .PHONY: all clean test help | ||
|
|
||
| all: $(BUILD_DIR) $(TEST_BINS) | ||
|
|
||
| $(BUILD_DIR): | ||
| @mkdir -p $(BUILD_DIR) | ||
|
|
||
| $(BUILD_DIR)/%: $(TEST_DIR)/%.c $(LIB_DIR)/tap.h | ||
| $(CC) $(CFLAGS) -o $@ $< | ||
|
|
||
| test: all | ||
| @echo "Running FIO mock tests..." | ||
| @echo "=========================" | ||
| @failed=0; \ | ||
| for test in $(TEST_BINS); do \ | ||
| echo "Running $$test..."; \ | ||
| ./$$test; \ | ||
| if [ $$? -ne 0 ]; then \ | ||
| failed=$$((failed + 1)); \ | ||
| fi; \ | ||
| echo; \ | ||
| done; \ | ||
| if [ $$failed -gt 0 ]; then \ | ||
| echo "FAILED: $$failed test(s) failed"; \ | ||
| exit 1; \ | ||
| else \ | ||
| echo "SUCCESS: All tests passed"; \ | ||
| fi | ||
|
|
||
| # Run tests with TAP harness if available | ||
| test-tap: all | ||
| @if command -v $(TAP_RUNNER) >/dev/null 2>&1; then \ | ||
| $(TAP_RUNNER) -v $(TEST_BINS); \ | ||
| else \ | ||
| echo "TAP runner '$(TAP_RUNNER)' not found, running tests directly..."; \ | ||
| $(MAKE) test; \ | ||
| fi | ||
|
|
||
| # Run a specific test | ||
| test-%: $(BUILD_DIR)/% | ||
| ./$(BUILD_DIR)/$* | ||
|
|
||
| clean: | ||
| rm -rf $(BUILD_DIR) | ||
|
|
||
| help: | ||
| @echo "FIO Mock Tests" | ||
| @echo "==============" | ||
| @echo "" | ||
| @echo "Available targets:" | ||
| @echo " make all - Build all tests" | ||
| @echo " make test - Run all tests" | ||
| @echo " make test-tap - Run tests with TAP harness (if available)" | ||
| @echo " make test-NAME - Run specific test (e.g., make test-latency_precision)" | ||
| @echo " make clean - Remove build artifacts" | ||
| @echo " make help - Show this help message" | ||
| @echo "" | ||
| @echo "Available tests:" | ||
| @for test in $(TESTS); do echo " - $$test"; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| # FIO Mock Tests | ||
|
|
||
| ## Overview | ||
|
|
||
| The FIO mock test suite provides isolated unit testing for specific algorithms, | ||
| calculations, and edge cases within FIO. These tests use mock implementations | ||
| to validate correctness without requiring the full FIO infrastructure. | ||
|
|
||
| ## Purpose and Goals | ||
|
|
||
| ### Why Mock Tests? | ||
|
|
||
| 1. **Isolation**: Test specific algorithms without full system dependencies | ||
| 2. **Precision**: Validate numerical calculations and edge cases precisely | ||
| 3. **Speed**: Run quickly without I/O operations or system calls | ||
| 4. **Clarity**: Each test focuses on a single aspect with clear documentation | ||
| 5. **Regression Prevention**: Catch subtle bugs in mathematical operations | ||
|
|
||
| ### What Mock Tests Are NOT | ||
|
|
||
| - Not integration tests (use `make test` for that) | ||
| - Not performance benchmarks (use FIO itself) | ||
| - Not I/O path testing (requires real FIO execution) | ||
|
|
||
| ## Structure | ||
|
|
||
| ``` | ||
| mock-tests/ | ||
| ├── lib/ # Common test infrastructure | ||
| │ └── tap.h # TAP (Test Anything Protocol) output support | ||
| ├── tests/ # Individual test programs | ||
| │ └── test_*.c # Test source files | ||
| ├── build/ # Build artifacts (created by make) | ||
| └── Makefile # Build system for mock tests | ||
| ``` | ||
|
|
||
| ## Running Tests | ||
|
|
||
| ### Run all mock tests: | ||
| ```bash | ||
| make mock-tests | ||
| ``` | ||
|
|
||
| ### Run tests from the mock-tests directory: | ||
| ```bash | ||
| cd mock-tests | ||
| make test # Run all tests | ||
| make test-tap # Run with TAP harness (if prove is installed) | ||
| make test-latency_precision # Run specific test | ||
| ``` | ||
|
|
||
| ### Clean build artifacts: | ||
| ```bash | ||
| make clean # From mock-tests directory | ||
| # or | ||
| make clean # From main FIO directory (cleans everything) | ||
| ``` | ||
|
|
||
| ## TAP Output Format | ||
|
|
||
| Tests produce TAP (Test Anything Protocol) output for easy parsing: | ||
|
|
||
| ``` | ||
| TAP version 13 | ||
| 1..12 | ||
| ok 1 - Microsecond latency: 123456000 == 123456000 | ||
| ok 2 - Millisecond latency: 1234567890000 == 1234567890000 | ||
| not ok 3 - Some failing test | ||
| # All tests passed | ||
| ``` | ||
|
|
||
| This format is understood by many test harnesses and CI systems. | ||
|
|
||
| ## Writing New Mock Tests | ||
|
|
||
| ### 1. Create test file in `tests/`: | ||
|
|
||
| ```c | ||
| #include "../lib/tap.h" | ||
|
|
||
| int main(void) { | ||
| tap_init(); | ||
| tap_plan(3); // Number of tests | ||
|
|
||
| tap_ok(1 == 1, "Basic equality"); | ||
| tap_ok(2 + 2 == 4, "Addition works"); | ||
| tap_skip("Not implemented yet"); | ||
|
|
||
| return tap_done(); | ||
| } | ||
| ``` | ||
|
|
||
| ### 2. Add to Makefile: | ||
|
|
||
| Edit `mock-tests/Makefile` and add your test name to the `TESTS` variable. | ||
|
|
||
| ### 3. Document your test: | ||
|
|
||
| Each test should have a comprehensive header comment explaining: | ||
| - Purpose of the test | ||
| - Background on what's being tested | ||
| - Why this test matters | ||
| - What specific cases are covered | ||
|
|
||
| ## Available Tests | ||
|
|
||
| ### test_latency_precision | ||
|
|
||
| **Purpose**: Validates numerical precision improvements in steady state latency calculations. | ||
|
|
||
| **Background**: When calculating total latency from mean and sample count, large values | ||
| can cause precision loss or overflow. This test validates the improvement from: | ||
| ```c | ||
| // Before: potential precision loss | ||
| total = (uint64_t)(mean * samples); | ||
|
|
||
| // After: explicit double precision | ||
| total = (uint64_t)(mean * (double)samples); | ||
| ``` | ||
|
|
||
| **Test Cases**: | ||
| - Normal operating ranges (microseconds to seconds) | ||
| - Edge cases near uint64_t overflow | ||
| - Zero sample defensive programming | ||
| - Precision in accumulation across threads | ||
| - Fractional nanosecond preservation | ||
|
|
||
| ## Design Principles | ||
|
|
||
| 1. **Isolation**: Mock only what's needed, test one thing at a time | ||
| 2. **Clarity**: Clear test names and diagnostic messages | ||
| 3. **Coverage**: Test normal cases, edge cases, and error conditions | ||
| 4. **Documentation**: Explain WHY each test exists | ||
| 5. **Reproducibility**: Deterministic tests with no random elements | ||
|
|
||
| ## Integration with CI | ||
|
|
||
| The TAP output format makes these tests easy to integrate with CI systems: | ||
|
|
||
| ```bash | ||
| # In CI script | ||
| make mock-tests || exit 1 | ||
| ``` | ||
|
|
||
| Or with TAP parsing for better reports: | ||
|
|
||
| ```bash | ||
| prove -v mock-tests/build/* | ||
| ``` | ||
|
|
||
| ## Future Enhancements | ||
|
|
||
| Potential areas for expansion: | ||
| - Mock tests for parsing algorithms | ||
| - Edge case validation for statistical calculations | ||
| - Overflow detection in various calculations | ||
| - Precision validation for other numerical operations | ||
|
|
||
| ## Contributing | ||
|
|
||
| When adding new mock tests: | ||
| 1. Follow the existing patterns | ||
| 2. Document thoroughly | ||
| 3. Use meaningful test descriptions | ||
| 4. Include both positive and negative test cases | ||
| 5. Test edge cases and boundary conditions |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.