Files
vigilcare-clinical/docs/performance/phase-42-resource-leaks-gc.md
T
Trent 68a2ab3204
CI / changes (push) Successful in 17s
CI / frontend (push) Skipped
CI / backend (push) Successful in 15m10s
Fix Kafka retry seek, bound buffers, and cut hot-path CPU/memory waste (Phases 41–44).
Stop consumers from committing past failed offsets, harden Rabbit/DataLake/gateway backpressure, dispose JsonDocument/MinIO correctly, and batch expensive DB/HTTP paths. Track progress in docs/performance.
2026-11-30 21:32:43 +08:00

38 lines
1.3 KiB
Markdown

# Phase 42 — Resource Leaks & GC
| Field | Value |
|-------|-------|
| Status | Complete |
| Audit findings | 4, 5, 8, 15 |
| Depends on | Phase 41 |
## Goal
Dispose pooled JSON parsers, stop creating MinIO clients per upload, reuse `JsonSerializerOptions` on Kafka hot paths, and await Redis threshold batch tasks.
## What to build
- [x] `using` for all hot-path `JsonDocument.Parse` (DataLakeEventParser + Rabbit/Kafka handlers)
- [x] Long-lived `IMinioClient` via DI; dispose `MemoryStream` on upload
- [x] Static shared `JsonSerializerOptions` on News2/Sofa/Gcs/Warning/Trend consumers (`ClinicalEventJson`)
- [x] Await Redis `StringSetAsync` tasks after `batch.Execute()` in both ThresholdCacheLoaders
## Key files
- `VigilCareClinicalAPI/DataLake/DataLakeEventParser.cs`
- `VigilCareClinicalAPI/Storage/MinioClientFactory.cs`
- `VigilCareClinicalAPI/DataLake/DataLakeWriterService.cs`
- Kafka scoring consumers; ThresholdCacheLoader (API + WardGateway)
## Acceptance criteria
- No undisposed JsonDocument on listed paths
- MinIO not constructed per upload
- Threshold cache load awaits all sets
- DataLake parser tests pass
## Verification notes
- MinIO registered as singleton `IMinioClient` in Program.cs; DataLake/Discharge paths inject it.
- Hot-path JsonDocument uses `using`; scoring consumers share `ClinicalEventJson.Options`.