Commit 3826f44
authored
Fix uninitialized aggregate_sampling_time_ms in Stats struct (#15820)
## Summary
Fixes a critical bug where `aggregate_sampling_time_ms` in the `Stats`
struct was not initialized, causing it to contain garbage data from
uninitialized memory.
## Problem
The `aggregate_sampling_time_ms` member variable was declared without
initialization:
```cpp
long aggregate_sampling_time_ms; // uninitialized!
```
This resulted in absurd sampling time reports like:
```
Sampling time over 68 tokens: 8433599.048000 (seconds) // ~97.5 days!
```
The actual sampling time should have been milliseconds, not millions of
seconds. Since the code accumulates timing data onto this variable
(`stats_.aggregate_sampling_time_ms += ...`), the garbage initial value
propagated through all calculations.
## Solution
Initialize the variable to zero in both locations:
`long aggregate_sampling_time_ms = 0;`
## Impact
After this fix, sampling time metrics will report realistic values
(e.g., 0.010-0.100 seconds for typical token generation) instead of
garbage values.1 parent 8e33788 commit 3826f44
2 files changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
0 commit comments