Skip to content

Commit 46ce7bb

Browse files
author
rhamlett_microsoft
committed
Removed reset-all endpoint and related code, updated thread block delay input to seconds.
1 parent 167bbfb commit 46ce7bb

13 files changed

Lines changed: 8 additions & 258 deletions

File tree

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ The slow request simulator generates requests using three different sync-over-as
159159

160160
| Endpoint | Method | Description |
161161
|----------|--------|-------------|
162-
| `/api/admin/reset-all` | POST | Release all memory and reset state |
163162
| `/api/admin/stats` | GET | Get current simulation statistics |
164163

165164
## ⏱️ Request Latency Monitor

specs/001-perf-problem-simulator/contracts/openapi.yaml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -295,45 +295,6 @@ paths:
295295
schema:
296296
$ref: '#/components/schemas/ThreadPoolMetrics'
297297

298-
/api/reset-all:
299-
post:
300-
tags:
301-
- Control
302-
summary: Reset all simulations
303-
description: |
304-
Stops all active CPU and thread blocking simulations, releases all allocated memory,
305-
and optionally forces garbage collection. Use this to return the application to
306-
baseline state.
307-
operationId: resetAll
308-
requestBody:
309-
required: false
310-
content:
311-
application/json:
312-
schema:
313-
type: object
314-
properties:
315-
forceGarbageCollection:
316-
type: boolean
317-
default: true
318-
responses:
319-
'200':
320-
description: All simulations reset
321-
content:
322-
application/json:
323-
schema:
324-
type: object
325-
properties:
326-
message:
327-
type: string
328-
example: All simulations have been reset
329-
simulationsStopped:
330-
type: integer
331-
example: 3
332-
memoryReleasedBytes:
333-
type: integer
334-
format: int64
335-
example: 524288000
336-
337298
/api/health:
338299
get:
339300
tags:

specs/001-perf-problem-simulator/data-model.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,6 @@ Represents a request to trigger sync-over-async thread blocking.
7979

8080
---
8181

82-
### ResetRequest
83-
84-
Represents a request to reset all active simulations.
85-
86-
| Field | Type | Required | Default | Constraints | Description |
87-
|-------|------|----------|---------|-------------|-------------|
88-
| `ForceGarbageCollection` | `bool` | No | true | N/A | Whether to force GC after releasing memory |
89-
90-
---
91-
9282
## Domain Models
9383

9484
### AllocatedMemoryBlock
@@ -105,7 +95,7 @@ Represents a chunk of memory intentionally held by the application.
10595
**Lifecycle:**
10696
1. Created when `/api/allocate-memory` is called
10797
2. Held in static collection (prevents GC)
108-
3. Released when `/api/release-memory` or `/api/reset-all` is called
98+
3. Released when `/api/release-memory` is called
10999
4. After release, GC may collect (timing not guaranteed)
110100

111101
---

specs/001-perf-problem-simulator/plan.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ src/
7777
│ ├── MemoryController.cs # POST /api/allocate-memory, POST /api/release-memory
7878
│ ├── ThreadBlockController.cs # POST /api/trigger-sync-over-async
7979
│ ├── MetricsController.cs # GET /api/metrics/*
80-
│ └── AdminController.cs # POST /api/reset-all
80+
│ └── AdminController.cs # GET /api/admin/stats
8181
8282
├── Services/ # Business logic
8383
│ ├── ICpuStressService.cs

specs/001-perf-problem-simulator/quickstart.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,6 @@ curl -X POST https://localhost:5001/api/trigger-sync-over-async `
109109
- Response times for ALL endpoints increase
110110
- CPU and memory appear normal (the key diagnostic clue!)
111111

112-
### Reset Everything
113-
114-
```powershell
115-
# Stop all simulations and release memory
116-
curl -X POST https://localhost:5001/api/reset-all
117-
```
118-
119112
---
120113

121114
## Environment Configuration

specs/001-perf-problem-simulator/tasks.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,8 @@
201201

202202
**Purpose**: Cross-cutting control features that affect multiple user stories
203203

204-
### Tests
205-
206-
- [ ] T063 [P] Integration test for POST /api/reset-all endpoint in tests/PerfProblemSimulator.Tests/Integration/AdminEndpointTests.cs
207-
208204
### Implementation
209205

210-
- [ ] T064 Create AdminController with POST /api/reset-all endpoint in src/PerfProblemSimulator/Controllers/AdminController.cs
211-
- [ ] T065 Implement reset logic: cancel active simulations, release memory, optional GC
212206
- [ ] T066 Add request logging for admin operations
213207

214208
---

src/PerfProblemSimulator/Controllers/AdminController.cs

Lines changed: 0 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -44,63 +44,6 @@ public AdminController(
4444
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
4545
}
4646

47-
/// <summary>
48-
/// Resets all active simulations and releases allocated memory.
49-
/// </summary>
50-
/// <remarks>
51-
/// <para>
52-
/// This endpoint performs a full reset of the simulator:
53-
/// </para>
54-
/// <list type="bullet">
55-
/// <item>Releases all allocated memory blocks</item>
56-
/// <item>Forces garbage collection</item>
57-
/// <item>Clears active simulation tracking (CPU/ThreadBlock simulations will complete naturally)</item>
58-
/// </list>
59-
/// <para>
60-
/// <strong>Note:</strong> CPU stress and thread blocking simulations cannot be instantly
61-
/// cancelled - they will complete their configured duration. Only memory allocations
62-
/// are immediately released.
63-
/// </para>
64-
/// </remarks>
65-
/// <returns>Summary of the reset operation.</returns>
66-
/// <response code="200">Reset completed successfully.</response>
67-
[HttpPost("reset-all")]
68-
[ProducesResponseType(typeof(ResetAllResponse), StatusCodes.Status200OK)]
69-
public IActionResult ResetAll()
70-
{
71-
var clientIp = HttpContext.Connection.RemoteIpAddress?.ToString();
72-
_logger.LogWarning(
73-
"⚠️ Reset-all requested from {ClientIP}. Releasing all resources...",
74-
clientIp);
75-
76-
// Get state before reset
77-
var activeSimulations = _simulationTracker.GetActiveSimulations();
78-
var memoryStatus = _memoryPressureService.GetMemoryStatus();
79-
80-
// Release memory (this also unregisters from tracker)
81-
var releaseResult = _memoryPressureService.ReleaseAllMemory(forceGc: true);
82-
83-
_logger.LogInformation(
84-
"Reset complete: Released {BlocksReleased} memory blocks ({BytesReleased} bytes), " +
85-
"had {ActiveSimulations} active simulations",
86-
releaseResult.ReleasedBlockCount,
87-
releaseResult.ReleasedBytes,
88-
activeSimulations.Count);
89-
90-
return Ok(new ResetAllResponse
91-
{
92-
Success = true,
93-
Message = "Reset completed. Memory released. Note: CPU and ThreadBlock simulations will complete naturally.",
94-
MemoryBlocksReleased = releaseResult.ReleasedBlockCount,
95-
BytesReleased = releaseResult.ReleasedBytes,
96-
ActiveSimulationsAtReset = activeSimulations.Count,
97-
SimulationTypesActive = activeSimulations
98-
.GroupBy(s => s.Type)
99-
.ToDictionary(g => g.Key.ToString(), g => g.Count()),
100-
GarbageCollectionForced = true
101-
});
102-
}
103-
10447
/// <summary>
10548
/// Gets current simulation statistics.
10649
/// </summary>
@@ -149,47 +92,6 @@ public IActionResult GetStats()
14992
}
15093
}
15194

152-
/// <summary>
153-
/// Response from the reset-all operation.
154-
/// </summary>
155-
public class ResetAllResponse
156-
{
157-
/// <summary>
158-
/// Whether the reset was successful.
159-
/// </summary>
160-
public bool Success { get; init; }
161-
162-
/// <summary>
163-
/// Human-readable message about the reset.
164-
/// </summary>
165-
public required string Message { get; init; }
166-
167-
/// <summary>
168-
/// Number of memory blocks that were released.
169-
/// </summary>
170-
public int MemoryBlocksReleased { get; init; }
171-
172-
/// <summary>
173-
/// Total bytes of memory that were released.
174-
/// </summary>
175-
public long BytesReleased { get; init; }
176-
177-
/// <summary>
178-
/// Number of active simulations at the time of reset.
179-
/// </summary>
180-
public int ActiveSimulationsAtReset { get; init; }
181-
182-
/// <summary>
183-
/// Breakdown of active simulations by type.
184-
/// </summary>
185-
public Dictionary<string, int> SimulationTypesActive { get; init; } = new();
186-
187-
/// <summary>
188-
/// Whether garbage collection was forced.
189-
/// </summary>
190-
public bool GarbageCollectionForced { get; init; }
191-
}
192-
19395
/// <summary>
19496
/// Current simulation statistics.
19597
/// </summary>

src/PerfProblemSimulator/wwwroot/css/dashboard.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -672,11 +672,6 @@ body {
672672
padding: 0.5rem 0.75rem;
673673
}
674674

675-
.reset-group {
676-
border-color: var(--color-primary);
677-
background: rgba(0, 120, 212, 0.05);
678-
}
679-
680675
/* --------------------------------------------------------------------------
681676
Latency Monitor Section
682677
-------------------------------------------------------------------------- */

src/PerfProblemSimulator/wwwroot/documentation.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -769,11 +769,6 @@ <h3>Admin Operations</h3>
769769
</tr>
770770
</thead>
771771
<tbody>
772-
<tr>
773-
<td><code>/api/admin/reset-all</code></td>
774-
<td><span class="method-badge method-post">POST</span></td>
775-
<td>Release all memory and reset state</td>
776-
</tr>
777772
<tr>
778773
<td><code>/api/admin/stats</code></td>
779774
<td><span class="method-badge method-get">GET</span></td>

src/PerfProblemSimulator/wwwroot/index.html

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ <h3>📊 Memory Pressure</h3>
7474
<h3>🧵 Thread Pool Starvation</h3>
7575
<p>Blocks threads using sync-over-async anti-pattern.</p>
7676
<div class="control-inputs">
77-
<label>Delay (ms):
78-
<input type="number" id="threadDelay" class="wide-input" value="5000" min="100" title="How long each blocking operation delays (minimum 100ms)">
77+
<label>Delay (s):
78+
<input type="number" id="threadDelay" class="wide-input" value="10" min="0.1" step="0.1" title="How long each blocking operation delays in seconds (minimum 0.1s)">
7979
</label>
8080
<label>Count:
8181
<input type="number" id="threadConcurrent" value="100" min="1" title="Number of concurrent blocking operations (minimum 1)">
@@ -124,11 +124,6 @@ <h3>💥 Application Crash</h3>
124124
<button class="btn btn-crash" id="btnTriggerCrash">💀 Trigger Crash</button>
125125
<p class="crash-warning">⚠️ This will TERMINATE the app!</p>
126126
</div>
127-
128-
<div class="control-group reset-group">
129-
<h3>🔄 Reset</h3>
130-
<button class="btn btn-secondary" id="btnResetAll" style="width: 100%;">🔄 Reset All Simulations</button>
131-
</div>
132127
</div>
133128
</aside>
134129

0 commit comments

Comments
 (0)