Commit c96a1c9
committed
fix: stop double counting jailer time in process_startup_time_cpu_us
In `report_cpu_start_time()`, Firecracker computers the CPU time it took
until the API socket was available as
CLOCK_PROCESS_CPUTIME_ID - cpu_start_time + jailer_time
However, here `cpu_start_time` is always zero currently (it's the value
the jailer passes via `--cpu-start-time`), and in the case where the
jailer exec()s into Firecracker (without prior fork() or clone()), this
is wrong: CLOCK_PROCESS_CPUTIME_ID will now be the CPU time since the
_jailer_ process started, and thus adding the jailer_time to it is
nonsense. This all works out if we set cpu_start_time to be the CPU time
right before we exec() into Firecracker: If we did not fork(), then it
will cause the calculation above to correctly discard all time before
exec()-ing into Firecracker (before re-adding specifically the time
spent in the jailer). If we _did_ fork(), then it will be approximately
zero, and thus preserve the current semantics (as the jailer time will
only be the time _until_ we did the last fork(), and
CLOCK_PROCESS_CPUTIME_ID will only be the absolute CPU time _since_ the
last fork()).
Signed-off-by: Patrick Roy <[email protected]>1 parent c1cc058 commit c96a1c9
1 file changed
+4
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
479 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
480 | 483 | | |
481 | 484 | | |
482 | 485 | | |
| |||
698 | 701 | | |
699 | 702 | | |
700 | 703 | | |
701 | | - | |
702 | | - | |
703 | 704 | | |
704 | 705 | | |
705 | 706 | | |
| |||
0 commit comments