Skip to content
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

Microsecond precision in chrome profile #2827

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions main/eval/src/mill/eval/EvaluatorCore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private[mill] trait EvaluatorCore extends GroupEvaluator {
.flatMap(_.iterator.flatMap(_.newResults))
.toMap

val startTime = System.currentTimeMillis()
val startTime = System.nanoTime() / 1000
val threadId = threadNumberer.getThreadId(Thread.currentThread())
val counterMsg = s"${count.getAndIncrement()}/${terminals.size}"
val contextLogger = PrefixLogger(
Expand All @@ -119,21 +119,23 @@ private[mill] trait EvaluatorCore extends GroupEvaluator {
if (failFast && res.newResults.values.exists(_.result.asSuccess.isEmpty))
failed.set(true)

val endTime = System.currentTimeMillis()
val endTime = System.nanoTime() / 1000

val duration = endTime - startTime

chromeProfileLogger.log(
task = Terminal.printTerm(terminal),
cat = "job",
startTime = startTime,
endTime = endTime,
duration = duration,
threadId = threadNumberer.getThreadId(Thread.currentThread()),
cached = res.cached
)

profileLogger.log(
ProfileLogger.Timing(
terminal.render,
(endTime - startTime).toInt,
(duration / 1000).toInt,
res.cached,
deps.map(_.render),
res.inputsHash,
Expand Down
6 changes: 3 additions & 3 deletions main/eval/src/mill/eval/JsonArrayLogger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private class ChromeProfileLogger(outPath: os.Path)
task: String,
cat: String,
startTime: Long,
endTime: Long,
duration: Long,
threadId: Int,
cached: Boolean
): Unit = {
Expand All @@ -68,8 +68,8 @@ private class ChromeProfileLogger(outPath: os.Path)
name = task,
cat = cat,
ph = "X",
ts = startTime * 1000,
dur = (endTime - startTime) * 1000 /*chrome treats the duration as microseconds*/,
ts = startTime,
dur = duration,
pid = 1,
tid = threadId,
args = if (cached) Seq("cached") else Seq()
Expand Down