^%SYS.MONLBL ルーチン行単位モニタリング

^%SYS.MONLBLユーティリティはパフォーマンス計測のためのユーティリティです。
このユーティリティを使うと、ルーチンのどの部分で処理に時間がかかっているかわかります。

モニタリングの開始

 USER>Do %SYS.MONLBL
  
WARNING ! Starting the line-by-line monitor will enable the collection
of statistics for *every* line of code executed by the selected routines
and processes. This can have a significant impact on the performance of a
system, and it is recommended that you do this on a 'test' system.

The line-by-line monitor also allocates shared memory to track these
statistics for each line of each routine selected. This is taken from
the general shared memory already allocated by Cache and should be
considered if you are using '*' wildcards and trying to analyze a large
number of routines. If the monitor fails to start due to a problem with
memory allocation, you may need to increase the GenericHeapSize parameter in
the system configuration. You may use the 'Memory Requirements' option to see
how much memory a collection would need (without starting the collection).

1.) Start Monitor
2.) Memory Requirements

Enter the number of your choice: 1

Enter routine names to be monitored on a line by line basis.
Patterns using '*' are allowed.
Enter '?L' to see a list of routines already selected.
Press 'Enter' to terminate input.

Routine Name: * (3 routines added to selection.) // * でそのネームスペースの全ルーチン対象
Routine Name: 	// Enterだけ入力で次に進む

Select Metrics to monitor
1) Monitor Minimal Metrics
2) Monitor Lines (Coverage)
3) Monitor Global Metrics
4) Monitor All Metrics
5) Customize Monitor Metrics

Enter the number of your choice: <1> 4

Select Processes to monitor
1) Monitor All Processes
2) Monitor Current Process Only
3) Enter list of PIDs

Enter the number of your choice: <1> 1

Monitor started.    // ここでfailedと表示される場合、メモリが確保できないためモニタリング開始できていません。

Press RETURN to continue ... 
Press RETURN to continue ... と表示されたらEnterを入力し、次の画面が表示されればモニタリングが開始されています。
Line-by-Line Monitor

1.) Stop Monitor
2.) Pause Monitor
3.) Clear Counters
4.) Report - Detail
5.) Report - Summary
6.) Report - Delimited (CSV) Output
7.) Report - Procedure Level

Enter the number of your choice:
この状態でルーチンを実行します。

Memory Allocation Failed

次のように表示されて、モニタリングが開始されないことがあります。
906 page(s) of memory required.
125 page(s) of memory available.

The GenericHeapSize parameter probably needs to be increased.
Pages are each 64kb of memory.

Memory allocation failed

Press RETURN to continue ...
これはモニタリングを動作させるのに必要なメモリが確保されていないことが原因ですので、次のような方法で回避します。

モニタリング結果の出力

測定したいルーチンを実行し終わったら、次の手順で結果をファイルに書き出します。
Line-by-Line Monitor

1.) Stop Monitor
2.) Pause Monitor
3.) Clear Counters
4.) Report - Detail
5.) Report - Summary
6.) Report - Delimited (CSV) Output
7.) Report - Procedure Level

Enter the number of your choice: 2 //最初にPause Monitorして、データ収集を止める


Line-by-Line Monitor

1.) Stop Monitor
2.) Resume Monitor
3.) Clear Counters
4.) Report - Detail
5.) Report - Summary
6.) Report - Delimited (CSV) Output
7.) Report - Procedure Level

Enter the number of your choice: 4
Include Coverage Analysis summary (Y/N)? Y

The following routines have been executed during the run,
and have detail statistics available for them.
1) Test
2) Fuka

Enter list of routines, or * for all
Routine number (*=All)? * - All
FileName: C:\temp\1.txt


Press RETURN to continue ...
出力されたファイルは、スペース整形されたテキストファイルになっていますので(CSV Outputを選択した場合を除く)、Excelのデータ→区切り位置の指定などを使って適宜整形してください。

ExcelでのMONLBL情報の表示 欲しい情報が取得できたことを確認したうえで、次の「モニタリングの終了」を行ってください。

モニタリングの終了

必要な結果が取得できたら、モニタリングを終了します。
Line-by-Line Monitor

1.) Stop Monitor
2.) Resume Monitor
3.) Clear Counters
4.) Report - Detail
5.) Report - Summary
6.) Report - Delimited (CSV) Output
7.) Report - Procedure Level

Enter the number of your choice: 1      // Stop Monitorを選択
 
WARNING ! Starting the line-by-line monitor will enable the collection
of statistics for *every* line of code executed by the selected routines
and processes. This can have a significant impact on the performance of a
system, and it is recommended that you do this on a 'test' system.

The line-by-line monitor also allocates shared memory to track these
statistics for each line of each routine selected. This is taken from
the general shared memory already allocated by Cache and should be
considered if you are using '*' wildcards and trying to analyze a large
number of routines. If the monitor fails to start due to a problem with
memory allocation, you may need to increase the GenericHeapSize parameter in
the system configuration. You may use the 'Memory Requirements' option to see
how much memory a collection would need (without starting the collection).

1.) Start Monitor
2.) Memory Requirements

Enter the number of your choice:      // 何も入力しないでEnter
USER>

モニタリングの結果確認

出力されたファイルには以下のような情報が含まれます。 (Report Detailの場合)

項目 概要
Line 行番号。ルーチンごとの先頭から振られる
GloRef グローバル読み込み回数
GloSet グローバル書き込み回数
GloKill グローバル削除回数
DirBlkRd データベースディレクトリブロック読み取り回数
UpntBlkRd データベース上位ポインタブロック読み取り回数
BpntBlkRd データベース下位ポインタブロック読み取り回数
DataBlkRd データベースデータブロック読み取り回数
RouBlkRd データベースルーチンブロック読み取り回数
MapBlkRd データベースマップブロック読み取り回数
OthBlkRd データベースその他ブロック読み取り回数
DirBlkWt データベースディレクトリブロック書き込み回数
UpntBlkWt データベース上位ポインタブロック書き込み回数
BpntBlkWt データベース下位ポインタブロック書き込み回数
DataBlkWt データベースデータブロック書き込み回数
RouBlkWt データベースルーチンブロック書き込み回数
MapBlkWt データベースマップブロック書き込み回数
OthBlkWt データベースその他ブロック書き込み回数
DirBlkBuf データベースディレクトリブロックバッファアクセス回数
UpntBlkBuf データベース上位ポインタブロックバッファアクセス回数
BpntBlkBuf データベース下位ポインタブロックバッファアクセス回数
DataBlkBuf データベースデータブロックバッファアクセス回数
RouBlkBuf データベースルーチンブロックバッファアクセス回数
MapBlkBuf データベースマップブロックバッファアクセス回数
OthBlkBuf データベースその他ブロックバッファアクセス回数
JrnEntry ジャーナル追加数
BlkAlloc 割り当てブロック数???
NetGloRef ,ネットワーク経由グローバル読み込み回数
NetGloSet ,ネットワーク経由グローバル書き込み回数
NetGloKill ,ネットワーク経由グローバル削除回数
NetReqSent ,ネットワーク経由要求送信回数
NCacheHit ネットワーク経由要求キャッシュヒット回数
NCacheMiss ネットワーク経由要求キャッシュ非ヒット回数
NetLock ネットワーク経由ロック要求数
RtnLine 行実行回数
RtnLoad 他の関数を呼び出した回数
RtnFetch ???
LockCom ロック要求回数
LockSucc ロック成功回数
LockFail ロック失敗回数
TermRead  
TermWrite  
TermChRd  
TermChWrt  
SeqRead  
SeqWrt  
IJCMsgRd  
IJCMsgWr  
IJCNetMsg  
Retransmit  
BuffSent  
Time その行の実行時間
TotalTime 呼び出し先を含めた実行時間

太字の項目をよくチェックします。
なお、モニタリング中は処理性能は通常の半分以下になりますので、Time欄はその点を考慮のうえで参考にしてください。

その他

公式: ^%SYS.MONLBL を使用したルーチン・パフォーマンスの検証


MONLBL : MONitor Line By Lineの略でしょうか。
Update