nsmcp::LogService object method updateTiming (public)

 nsmcp::LogService[i] updateTiming recordVar sliceStarted [ finished ] \
    [ now ]

Defined in /usr/local/ns/tcl/nsmcp/log-tools.tcl

Update elapsed and worker timing on a background job. Elapsed time includes queueing and gaps between slices. Worker time includes I/O and SQL waits.

Parameters:
recordVar (required)
Caller variable containing the job record to update.
sliceStarted (required)
Start time in milliseconds, or empty for a snapshot.
finished (optional, defaults to "false")
Whether this update marks the job finished.
now (optional)
Optional observation time in milliseconds.
Returns:
No meaningful value. The caller’s record is updated in place.

Testcases:
No testcase defined.
Source code:
upvar 1 $recordVar record
if {![dict exists $record queuedMs]} {
    return
}
if {$now eq {}} {
    set now [clock milliseconds]
}
if {$sliceStarted ne {}} {
    dict incr record workerMs [expr {max(0,$now-$sliceStarted)}]
    dict unset record currentSliceStartedMs
}
if {$finished} {
    dict set record finishedMs $now
}
if {[dict exists $record finishedMs]} {
    set now [dict get $record finishedMs]
}
set wall [expr {max(0,$now-[dict get $record queuedMs])}]
set execution [dict get $record workerMs]
if {[dict exists $record currentSliceStartedMs] && ![dict exists $record finishedMs]} {
    incr execution [expr {max(0,$now-[dict get $record currentSliceStartedMs])}]
}
set queueWait $wall
if {[dict exists $record firstStartedMs]} {
    set queueWait [expr {max(0,[dict get $record firstStartedMs]-[dict get $record queuedMs])}]
}
set fields [list wallMs number $wall workerMs number [dict get $record workerMs] scope string background-job-excluding-model-and-browser workerTimeIsCpu boolean false]
if {[dict exists $record firstStartedMs]} {
    lappend fields initialQueueMs number [expr {max(0,[dict get $record firstStartedMs]-[dict get $record queuedMs])}]
}
lappend fields queueWaitMs number $queueWait executionMs number $execution  betweenSlicesMs number [expr {max(0,$wall-$queueWait-$execution)}]
dict set record processingTime $fields
if {[dict exists $record progress]} {
    set progress {}
    foreach {key type value} [dict get $record progress] {
        if {$key ne "wallMs"} {
            lappend progress $key $type $value
        }
    }
    dict set record progress [concat $progress [list wallMs number $wall]]
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: