From f07c03e68b9649b087c2876cd8aaeb8fdb824384 Mon Sep 17 00:00:00 2001 From: iipeace Date: Thu, 31 Oct 2024 22:27:38 +0900 Subject: [PATCH] memtest: Improve random chunk allocation performance Signed-off-by: iipeace --- guider/guider.py | 246 +++++++++++++++++++++++------------------------ 1 file changed, 122 insertions(+), 124 deletions(-) diff --git a/guider/guider.py b/guider/guider.py index 7302d113..91a68d0c 100755 --- a/guider/guider.py +++ b/guider/guider.py @@ -7,7 +7,7 @@ __credits__ = "Peace Lee" __license__ = "GPLv2" __version__ = "3.9.8" -__revision__ = "241030" +__revision__ = "241031" __maintainer__ = "Peace Lee" __email__ = "iipeace5@gmail.com" __repository__ = "https://github.com/iipeace/guider" @@ -38146,7 +38146,7 @@ def getCmdList(): "irqtop": ("IRQ", "Linux"), "kftop": ("Function", "Linux"), "ktop": ("Function", "Linux"), - "mdtop": ("MemDump", "Linux"), + "mdtop": ("Memory", "Linux"), "mtop": ("Memory", "Linux"), "ntop": ("Network", "Linux/MacOS/Windows"), "ptop": ("PMU", "Linux"), @@ -40628,7 +40628,8 @@ def _getDesc(s, t=0): elif SysMgr.checkMode("ftop"): fileTopStr = topCommonStr - helpStr = _getDesc("Monitor open files on the system") + desc = "Monitor open files, sockets, pipes" + helpStr = _getDesc(desc) examStr = """ Examples: @@ -40681,7 +40682,7 @@ def _getDesc(s, t=0): See the top COMMAND help for more examples. """.format( - cmd, mode, "Monitor open files, sockets, pipes" + cmd, mode, desc ) helpStr += fileTopStr + examStr @@ -40888,7 +40889,8 @@ def _getDesc(s, t=0): # kernel function top # elif SysMgr.checkMode("kftop"): - helpStr = _getDesc("Monitor kernel function calls", t=1) + desc = "Monitor kernel function calls" + helpStr = _getDesc(desc, t=1) helpStr += """ Options: @@ -40926,7 +40928,7 @@ def _getDesc(s, t=0): """.format( cmd, mode, - "Monitor kernel function calls", + desc ) # kernel top # @@ -41084,9 +41086,8 @@ def _getDesc(s, t=0): # atrace top # elif SysMgr.checkMode("attop"): - helpStr = _getDesc( - "Monitor atrace events", - ) + desc = "Monitor atrace events" + helpStr = _getDesc(desc) examStr = """ Examples: @@ -41120,16 +41121,15 @@ def _getDesc(s, t=0): """.format( cmd, mode, - "Monitor atrace events", + desc ) helpStr += topCommonStr + examStr # memory dump top # elif SysMgr.checkMode("mdtop"): - helpStr = _getDesc( - "Monitor memory details for a process using dumpsys meminfo", - ) + desc = "Monitor memory details for a process using dumpsys" + helpStr = _getDesc(desc) examStr = """ Examples: @@ -41141,7 +41141,7 @@ def _getDesc(s, t=0): """.format( cmd, mode, - "Monitor memory details for a process using dumpsys meminfo", + desc, ) helpStr += topSubStr + topCommonStr + examStr @@ -41433,18 +41433,17 @@ def _getDesc(s, t=0): # stack top # elif SysMgr.checkMode("stacktop"): - helpStr = _getDesc( - "Monitor kernel stacks for specific threads", t=3 - ) + desc = "Monitor kernel stacks for specific threads" + helpStr = _getDesc(desc, t=3) examStr = """ Examples: - - Monitor kernel stacks for specific threads + - {2:1} # {0:1} {1:1} -g chrome See the top COMMAND help for more examples. """.format( - cmd, mode + cmd, mode, desc ) helpStr += topSubStr + topCommonStr + examStr @@ -41537,10 +41536,8 @@ def _getDesc(s, t=0): # wss top # elif SysMgr.checkMode("wtop"): - helpStr = _getDesc( - "Monitor WSS(Working Set Size) for specific processes", - t=2, - ) + desc = "Monitor WSS(Working Set Size) for specific processes" + helpStr = _getDesc(desc, t=2) examStr = r""" Examples: @@ -41558,9 +41555,7 @@ def _getDesc(s, t=0): See the top COMMAND help for more examples. """.format( - cmd, - mode, - "Monitor WSS(Working Set Size) of specific processes", + cmd, mode, desc, ) helpStr += topSubStr + topCommonStr + examStr @@ -41633,18 +41628,17 @@ def _getDesc(s, t=0): # irq top # elif SysMgr.checkMode("irqtop"): - helpStr = _getDesc( - "Monitor the status of irqs on the system" - ) + desc = "Monitor the status of irqs on the system" + helpStr = _getDesc(desc) examStr = """ Examples: - - Monitor the status of all irqs + - {2:1} # {0:1} {1:1} See the top COMMAND help for more examples. """.format( - cmd, mode + cmd, mode, desc ) helpStr += topSubStr + topCommonStr + examStr @@ -41684,7 +41678,8 @@ def _getDesc(s, t=0): # ANDROID top # elif SysMgr.checkMode("andtop"): - helpStr = _getDesc("Monitor android logs") + desc = "Monitor android logs" + helpStr = _getDesc(desc) examStr = """ Examples: @@ -41712,14 +41707,15 @@ def _getDesc(s, t=0): See the top COMMAND help for more examples. """.format( - cmd, mode, "Monitor android logs" + cmd, mode, desc, ) helpStr += topSubStr + topCommonStr + examStr # DLT top # elif SysMgr.checkMode("dlttop"): - helpStr = _getDesc("Monitor DLT logs") + desc = "Monitor DLT logs" + helpStr = _getDesc(desc) examStr = """ Examples: @@ -41754,14 +41750,15 @@ def _getDesc(s, t=0): See the top COMMAND help for more examples. """.format( - cmd, mode, "Monitor DLT logs" + cmd, mode, desc, ) helpStr += topSubStr + topCommonStr + examStr # dbus top # elif SysMgr.checkMode("dbustop"): - helpStr = _getDesc("Monitor D-Bus messages") + desc = "Monitor D-Bus messages" + helpStr = _getDesc(desc) examStr = """ Examples: @@ -41796,7 +41793,7 @@ def _getDesc(s, t=0): See the top COMMAND help for more examples. """.format( - cmd, mode, "Monitor D-Bus messages" + cmd, mode, desc ) helpStr += topSubStr + topCommonStr + examStr @@ -41827,14 +41824,15 @@ def _getDesc(s, t=0): # mount # elif SysMgr.checkMode("mount"): + desc = "Mount filesystem" helpStr = """ Usage: # {0:1} {1:1} -I [OPTIONS] [--help] Description: - Mount filesystem + {2:1} """.format( - cmd, mode + cmd, mode, desc ) helpStr += """ @@ -41850,26 +41848,27 @@ def _getDesc(s, t=0): helpStr += """ Examples: - - Mount filesystem + - {2:1} # {0:1} {1:1} "/dev/sda1:/data/fs:ext4" # {0:1} {1:1} -I "/dev/sda1:/data/fs:ext4" - Remount filesystem # {0:1} {1:1} "/dev/sda1:/data/fs:ext4:REMOUNT,RDONLY" """.format( - cmd, mode + cmd, mode, desc ) # umount # elif SysMgr.checkMode("umount"): + desc = "Unmount filesystem" helpStr = """ Usage: # {0:1} {1:1} -I [OPTIONS] [--help] Description: - Unmount filesystem + {2:1} """.format( - cmd, mode + cmd, mode, desc ) helpStr += """ @@ -41885,11 +41884,11 @@ def _getDesc(s, t=0): helpStr += """ Examples: - - Unmount filesystem + - {2:1} # {0:1} {1:1} "/dev/sda1" # {0:1} {1:1} -I "/dev/sda1" """.format( - cmd, mode + cmd, mode, desc ) # getpid # @@ -41942,7 +41941,8 @@ def _getDesc(s, t=0): # less # elif SysMgr.checkMode("less"): - helpStr = _getDesc("Print files, pipe with pager", t=5) + desc = "Print files, pipe with pager" + helpStr = _getDesc(desc, t=5) helpStr += """ Options: @@ -41979,7 +41979,7 @@ def _getDesc(s, t=0): # {0:1} {1:1} a.out # {0:1} {1:1} -I a.out """.format( - cmd, mode, "Print files, pipe with pager" + cmd, mode, desc ) # strings # @@ -42020,14 +42020,15 @@ def _getDesc(s, t=0): # sysrq # elif SysMgr.checkMode("sysrq"): + desc = "Write values to sysrq" helpStr = """ Usage: # {0:1} {1:1} VAL [OPTIONS] [--help] Description: - Write values to sysrq + {2:1} """.format( - cmd, mode + cmd, mode, desc ) helpStr += """ @@ -42040,14 +42041,14 @@ def _getDesc(s, t=0): helpStr += """ Examples: - - Write values to sysrq + - {2:1} # {0:1} {1:1} b # {0:1} {1:1} dle - Print values for sysrq # {0:1} {1:1} -l """.format( - cmd, mode + cmd, mode, desc ) # cgroup # @@ -42135,8 +42136,9 @@ def _getDesc(s, t=0): # print # elif SysMgr.checkMode("print"): + desc = "Print target files" helpStr = _getDesc( - "Print files including compressed data", t=5 + "%s including compressed data" % desc, t=5 ) helpStr += """ @@ -42153,19 +42155,19 @@ def _getDesc(s, t=0): helpStr += """ Examples: - - Print target files + - {4:1} # {0:1} {1:1} -I a.out, a.tar, a.zip, a.gz, a.apk, a.xz, a.z # {0:1} {1:1} {2:1} -q EXCEPTFILE:"*100*" # {0:1} {1:1} -I a.zip -q PRINTRAW - - Print target files in compressed and BASE64-encoded data + - {4:1} in compressed and BASE64-encoded data # {0:1} {1:1} {3:1} test.xz.base64 -q BASE64 # {0:1} {1:1} {3:1} test.gz.base64 -q BASE64 - Print specific lines including specific words for target files # {0:1} {1:1} {2:1} -g "peace, best" - - Print target files to the output file + - {4:1} to the output file # {0:1} {1:1} {2:1} -o output.txt - Print the contents of target files as much as a specified size @@ -42180,14 +42182,14 @@ def _getDesc(s, t=0): # {0:1} {1:1} {2:1} -q TAIL:"2024-06-25 12:00:00.000" # {0:1} {1:1} {2:1} -q TAIL:100, CONT - - Print target files in specific list + - {4:1} in specific list # {0:1} {1:1} {2:1} -q FILELIST:-1 # {0:1} {1:1} {2:1} -q FILELIST:0:10 - Print specific target files in compressed data # {0:1} {1:1} {3:1} -g "*.so" - - Print target files in compressed data in tree structure + - {4:1} in compressed data in tree structure # {0:1} {1:1} {3:1} -q PRINTTREE # {0:1} {1:1} {3:1} -q PRINTTREE, INCFILTER:"*test*", EXFILTER:"*zip" @@ -42201,6 +42203,7 @@ def _getDesc(s, t=0): mode, '"a.out, test*.txt"', '"a.zip, test*.apk"', + desc, ) # dump # @@ -42871,10 +42874,8 @@ def _getDesc(s, t=0): # hprof # elif SysMgr.checkMode("hprof"): - helpStr = _getDesc( - "Record function calls allocating memory using perfetto", - t=1, - ) + desc = "Record function calls allocating memory" + helpStr = _getDesc(desc + " using perfetto", t=1) helpStr += """ Options: @@ -42988,15 +42989,14 @@ def _getDesc(s, t=0): """.format( cmd, mode, - "Record function calls allocating memory using perfetto", + desc, "-q TASKMON", ) # sperf # elif SysMgr.checkMode("sperf"): - helpStr = _getDesc( - "Record function calls using CPU using simpleperf", t=1 - ) + desc = "Record function calls consuming CPU" + helpStr = _getDesc(desc + "using simpleperf", t=1) helpStr += """ Options: @@ -43117,7 +43117,7 @@ def _getDesc(s, t=0): """.format( cmd, mode, - "Record function calls using CPU", + desc, "-q TASKMON", ) @@ -43277,9 +43277,8 @@ def _getDesc(s, t=0): # draw diff # elif SysMgr.checkMode("drawdiff"): - helpStr = _getDesc( - "Draw diff graphs between report files", t=5 - ) + desc = "Draw diff graphs between report files" + helpStr = _getDesc(desc, t=5) myStr = """ - {2:1} @@ -43287,7 +43286,7 @@ def _getDesc(s, t=0): """.format( cmd, mode, - "Draw diff graphs between report files", + desc, ) helpStr += drawSubStr + drawExamStr + myStr @@ -43295,14 +43294,12 @@ def _getDesc(s, t=0): # flamegraph draw # elif SysMgr.checkMode(["drawflame", "drawflamediff"]): if SysMgr.checkMode("drawflame"): - helpStr = _getDesc("Draw flame graph", t=5) commonStr = "Draw a flame graph" + helpStr = _getDesc(commonStr, t=5) addStr = "" else: - helpStr = _getDesc( - "Draw differential flame graph", t=5 - ) commonStr = "Draw a differential flame graph" + helpStr = _getDesc(commonStr, t=5) addStr = """ - {2:1} between two files # {0:1} drawflame guider1.out.gz -q SAVESAMPLE:guider1.sample @@ -43521,7 +43518,8 @@ def _getDesc(s, t=0): # topdiff # elif SysMgr.checkMode("topdiff"): - helpStr = _getDesc("Diff top report files", t=5) + desc = "Diff top report files" + helpStr = _getDesc(desc, t=5) helpStr += """ Options: @@ -43606,14 +43604,13 @@ def _getDesc(s, t=0): - {2:1} in JSON format # {0:1} {1:1} "tc*.out" -J """.format( - cmd, mode, "Diff top report files" + cmd, mode, desc ) # topsum # elif SysMgr.checkMode("topsum"): - helpStr = _getDesc( - "Summarize a raw file for task top mode", t=5 - ) + desc = "Summarize raw data of the top report files" + helpStr = _getDesc(desc, t=5) helpStr += """ Options: @@ -43721,7 +43718,7 @@ def _getDesc(s, t=0): """.format( cmd, mode, - "Summarize raw data of the top report files", + desc, '"report*.out" -q CLASSIFYGROUP', ) @@ -43772,8 +43769,9 @@ def _getDesc(s, t=0): # pause # elif SysMgr.checkMode("pause"): + desc = "Pause specific threads" helpStr = ( - _getDesc("Pause specific threads", t=3) + _getDesc(desc, t=3) + """ Options: -g set task filter @@ -43786,15 +43784,15 @@ def _getDesc(s, t=0): helpStr += """ Examples: - - Pause specific threads for 3 seconds + - {2:1} for 3 seconds # {0:1} {1:1} -g a.out -R 3 # {0:1} {1:1} -g 1234 -R 3 # {0:1} {1:1} -g "a*" -R 3 - - Pause specific threads including a same process group + - {2:1} including a same process group # {0:1} {1:1} -g a.out -P """.format( - cmd, mode + cmd, mode, desc ) # freeze # @@ -44276,11 +44274,9 @@ def _getDesc(s, t=0): # checkdup# elif SysMgr.checkMode("checkdup"): + desc = "Check duplicated page frames of specific processes" helpStr = ( - _getDesc( - "Check duplicated page frames of specific processes", - t=2, - ) + _getDesc(desc, t=2) + """ Options: -I set input path @@ -44385,7 +44381,7 @@ def _getDesc(s, t=0): """.format( cmd, mode, - "Check all duplicated page frames of specific processes", + desc, "from leaktrace or mtrace reports", "-I guider.out -q SHOWMEM", ) @@ -45606,8 +45602,9 @@ def _getDesc(s, t=0): # split # elif SysMgr.checkMode("split"): + desc = "Split files" helpStr = ( - _getDesc("Split files", t=5) + _getDesc(desc, t=5) + """ Options: -o set output path @@ -45618,28 +45615,29 @@ def _getDesc(s, t=0): helpStr += """ Examples: - - Split files to 10M size + - {2:1} to 10M size # {0:1} {1:1} "guider.tgz, guider2.tgz" -q CHUNK:10m - - Split files into 5 files each + - {2:1} into 5 files each # {0:1} {1:1} "guider.tgz, guider2.tgz" -q COUNT:5 - - Split files into 5 files of 10M size each + - {2:1} into 5 files of 10M size each # {0:1} {1:1} "guider.tgz, guider2.tgz" -q CHUNK:10M, COUNT:5 - - Split files into 5 files of 10M size each from the back + - {2:1} into 5 files of 10M size each from the back # {0:1} {1:1} "guider.tgz, guider2.tgz" -q CHUNK:10M, COUNT:5, TAIL - - Split files to 10M size with file filter + - {2:1} to 10M size with file filter # {0:1} {1:1} "guider*.tgz" -q CHUNK:10m, TARGETFILE:"*.tgz", EXCEPTFILE:"*1*" """.format( - cmd, mode + cmd, mode, desc ) # merge # elif SysMgr.checkMode("merge"): + desc = "Merge files" helpStr = ( - _getDesc("Merge files", t=5) + _getDesc(desc, t=5) + """ Options: -o set output path @@ -45650,13 +45648,13 @@ def _getDesc(s, t=0): helpStr += """ Examples: - - Merge files into a new file + - {2:1} into a new file # {0:1} {1:1} "guider.tgz, guider2.tgz" -o guiderMerged.mg - - Merge files into a new file with file filter + - {2:1} into a new file with file filter # {0:1} {1:1} "guider*.tgz" -o guiderMerged.mg -q TARGETFILE:"*.tgz", EXCEPTFILE:"*1*" """.format( - cmd, mode + cmd, mode, desc ) # comp # @@ -45755,7 +45753,7 @@ def _getDesc(s, t=0): # systat # elif SysMgr.checkMode("systat"): helpStr = ( - _getDesc("Print system status") + _getDesc("Show system status") + """ Options: -e enable options @@ -46002,8 +46000,9 @@ def _getDesc(s, t=0): # convert # elif SysMgr.checkMode("convert"): + desc = "Convert a text file to a image file" helpStr = ( - _getDesc("Convert a text file to a image file") + _getDesc(desc) + """ Options: -v verbose @@ -46012,10 +46011,10 @@ def _getDesc(s, t=0): helpStr += """ Examples: - - Convert a text file to a image file + - {2:1} # {0:1} {1:1} guider.out """.format( - cmd, mode + cmd, mode, desc ) # drawreq # @@ -46189,7 +46188,7 @@ def _getDesc(s, t=0): # printkconf # elif SysMgr.checkMode("printkconf"): helpStr = ( - _getDesc("Print kernel configs") + _getDesc("Show kernel configs") + """ Options: -g