-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sperf: Add TASKMON and PROCGROUP variables
Signed-off-by: iipeace <[email protected]>
- Loading branch information
Showing
1 changed file
with
56 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
__credits__ = "Peace Lee" | ||
__license__ = "GPLv2" | ||
__version__ = "3.9.8" | ||
__revision__ = "240716" | ||
__revision__ = "240717" | ||
__maintainer__ = "Peace Lee" | ||
__email__ = "[email protected]" | ||
__repository__ = "https://github.com/iipeace/guider" | ||
|
@@ -25858,7 +25858,9 @@ def printAndLog(console=False): | |
datetime = SysMgr.getPkg("datetime") | ||
epochStart = datetime.datetime(1900, 1, 1) | ||
SysMgr.addEnvironVar("TIMEUNIT", "ms") | ||
barLen = UtilMgr.getEnvironNum("BARLEN", False, 100, False, True) | ||
barLen = UtilMgr.getEnvironNum( | ||
"BARLEN", False, 100000, False, True | ||
) | ||
|
||
# set output path # | ||
outFile = SysMgr.outPath if SysMgr.outPath else "guider" | ||
|
@@ -25955,7 +25957,7 @@ def printAndLog(console=False): | |
start = ( | ||
datetime.datetime.strptime(items[1], "%H:%M:%S.%f") | ||
- epochStart | ||
).total_seconds() * 1000 | ||
).total_seconds() * 1000000 | ||
if startTime == 0: | ||
startTime = start | ||
start -= startTime | ||
|
@@ -26032,7 +26034,6 @@ def printAndLog(console=False): | |
SysMgr.drawTimeline( | ||
inputData=taskObj.timelineData, | ||
outputPath=timelineOutput, | ||
start=startTime, | ||
) | ||
|
||
# child # | ||
|
@@ -41414,6 +41415,21 @@ def _getDesc(s, t=0): | |
- {2:1} and report to the specific output file with task filter | ||
# {0:1} {1:1} -q TASKFILTER:"*task" | ||
|
||
- {2:1} and report to the specific output file with process grouping | ||
# {0:1} {1:1} -q PROCGROUP | ||
|
||
- {2:1} with monitoring and report to the specific output file | ||
# {0:1} {1:1} -q TASKMON | ||
# {0:1} {1:1} -q TASKMON:3 | ||
# {0:1} {1:1} -q TASKMON -a | ||
# {0:1} {1:1} -q TASKMON, TASKFILTER:"*a.out*" | ||
# {0:1} {1:1} -q TASKMON, TASKFILTER:"*a.out*" -e t -P | ||
# {0:1} {1:1} -q TASKMON, CHILDSCHED:c:0 -Y r:1 | ||
# {0:1} {1:1} -q TASKMON, EXECSCHED:c:0 -Y r:1 | ||
|
||
- {2:1} and report to the specific output file | ||
# {0:1} {1:1} -q REPSCHED:i:0 | ||
|
||
- {2:1} and report to per-task output files | ||
# {0:1} {1:1} -q EACHFILE | ||
|
||
|
@@ -56512,6 +56528,12 @@ def doSimplePerfRec(): | |
# backup an exist file # | ||
SysMgr.backupFile(outPath) | ||
|
||
# start monitoring # | ||
if "TASKMON" in SysMgr.environList: | ||
monPid = SysMgr.runTaskMonitor([""], wait=False) | ||
else: | ||
monPid = 0 | ||
|
||
# print record status # | ||
SysMgr.printStat(r"start profiling... [ STOP(Ctrl+c) ]") | ||
if SysMgr.warnEnable: | ||
|
@@ -56521,9 +56543,15 @@ def doSimplePerfRec(): | |
try: | ||
SysMgr.executeCmdSync(cmd) | ||
except: | ||
recPid = set(SysMgr.getChildList()) - set([monPid]) | ||
if recPid: | ||
recPid = recPid.pop() | ||
|
||
SysMgr.repeatCnt = 0 | ||
SysMgr.killChildren(sig=signal.SIGINT) | ||
SysMgr.waitChild() | ||
|
||
if recPid: | ||
SysMgr.waitChild(recPid) | ||
|
||
# check record file # | ||
if not os.path.exists(outPath): | ||
|
@@ -56540,6 +56568,10 @@ def doSimplePerfRec(): | |
# set default handler for force termination # | ||
SysMgr.setDefaultSignal() | ||
|
||
# apply report sched # | ||
for cmd in SysMgr.environList.get("REPSCHED", []): | ||
SysMgr.applyPriority("%s:%s" % (cmd, SysMgr.pid)) | ||
|
||
# print report status # | ||
SysMgr.printStat(r"start reporting... [ STOP(Ctrl+c) ]") | ||
|
||
|
@@ -56639,6 +56671,7 @@ def convSimplePerfSample(path, scripts=[]): | |
taskList = {} | ||
totalTaskList = {} | ||
taskObjList = {} | ||
tgidList = {} | ||
convNum = UtilMgr.convNum | ||
|
||
# define _getSym # | ||
|
@@ -56657,6 +56690,7 @@ def _getSym(call): | |
exceptKernel = "EXCEPTKERNEL" in SysMgr.environList | ||
hasStackFilter = targetKernel or exceptKernel | ||
taskFilter = SysMgr.environList.get("TASKFILTER", []) | ||
procGroup = "PROCGROUP" in SysMgr.environList | ||
|
||
# parse lines # | ||
totalCnt = 0 | ||
|
@@ -56683,7 +56717,7 @@ def _getSym(call): | |
sample["backtrace"] = callchain | ||
|
||
# check task object # | ||
origTid = tid = sample.get("thread_id") | ||
tid = sample.get("thread_id") | ||
if not tid: | ||
SysMgr.printErr( | ||
"failed to get thread id info from a sample" | ||
|
@@ -56695,8 +56729,17 @@ def _getSym(call): | |
|
||
continue | ||
|
||
# group thread # | ||
comm = None | ||
if procGroup and tid != "0": | ||
tgid = tgidList.get(tid, SysMgr.getTgid(tid)) | ||
if tgid and tgid != tid: | ||
tid = tgidList[tid] = tgid | ||
comm = SysMgr.getComm(tid, save=True) | ||
|
||
# get task info # | ||
comm = sample.get("thread_name") | ||
if not comm: | ||
comm = sample.get("thread_name") | ||
current = float(sample.get("time", 0)) / 1000000000 | ||
totalTaskList[tid] = 0 | ||
|
||
|
@@ -57819,9 +57862,8 @@ def executeProcess(cmd=None, mute=False, closeFd=True): | |
) | ||
|
||
# set priority # | ||
if "EXECSCHED" in SysMgr.environList: | ||
for cmd in SysMgr.environList["EXECSCHED"]: | ||
SysMgr.applyPriority(cmd) | ||
for cmd in SysMgr.environList.get("EXECSCHED", []): | ||
SysMgr.applyPriority(cmd) | ||
|
||
# exec # | ||
try: | ||
|
@@ -58399,9 +58441,8 @@ def createProcess( | |
SysMgr.childList[pid] = True | ||
|
||
# set child priority # | ||
if "CHILDSCHED" in SysMgr.environList: | ||
for cmd in SysMgr.environList["CHILDSCHED"]: | ||
SysMgr.applyPriority("%s:%s" % (cmd, pid)) | ||
for cmd in SysMgr.environList.get("CHILDSCHED", []): | ||
SysMgr.applyPriority("%s:%s" % (cmd, pid)) | ||
|
||
return pid | ||
# child # | ||
|
@@ -70505,9 +70546,8 @@ def _exeCmd(cmd, seq=1, repeat=1): | |
# procObj.stdin.close() | ||
|
||
# set priority # | ||
if "EXECSCHED" in SysMgr.environList: | ||
for cmd in SysMgr.environList["EXECSCHED"]: | ||
SysMgr.applyPriority("%s:%s" % (cmd, procObj.pid)) | ||
for cmd in SysMgr.environList.get("EXECSCHED", []): | ||
SysMgr.applyPriority("%s:%s" % (cmd, procObj.pid)) | ||
|
||
# wait for worker process # | ||
try: | ||
|