Closed select766 closed 4 months ago
ponder局面
position startpos moves 7g7f 5a6b 2g2f 3c3d 2f2e 2b8h+ 7i8h 3a2b 8h7g 1c1d 2e2d 2c2d 2h2d P*2c 2d2e 2a3c 2e2h 4a4b 5i6h B*6e 4i5h 4b3b 3i4h 1d1e 3g3f 6c6d 3f3e 3d3e P*3d 3e3f 3d3c+ 3b3c 6h7h 2c2d 9g9f 6b5b 4g4f 4c4d 4h4g 6e5d 4g5f 3f3g+ 2i3g P*3f P*3h 3f3g+ 3h3g N*2g 4f4e 2g1i+ 4e4d L*4b 5f5e 5d6e N*5f 7a6b P*2e 2d2e 2h2e P*2d 2e2f 5b5a 5e6d 6e5d 3g3f P*3g 5h4h 1i1h 4h3g 1h1g 2f2i 5d6e 3g4f 2b3a P*1b 1a1b B*1a 3c2c P*2e 1g1h 2i4i 2d2e P*2d 2c1c 1a3c+ 3a3b 3c2b 3b2a 2b3a P*3g 4f5e 6e3b 4d4c+ 4b4c P*4d 6a5b 4d4c+ 3b4c 4i4c+ 5b4c 3a2a 3g3h+ 2a4c R*4h 6i6h 4h4c+ 5e4d 4c4a 6d5c 6b5c 4d5c
最後のメッセージ
dispatch USIActorMessage usiRecv(commandType: "info", commandArg: Optional("nps 4413 time 195075 nodes 860880 hashfull 90 depth 18 score cp 1931 pv 4d5c B*7a B*3c S*4b 5c4b 8b4b 3c4b+ 4a4b P*4d P*4f L*4c B*6i 6h6i G*8h 7h8h 4b4c 4d4c+ P*3a"))
相手の思考結果を受信する前にクラッシュしてる。
USIモードでまずは数分放置してみる
ここでクラッシュした。
Xcodeでデバッグ実行していたので、このようなメッセージが出た。
Show Detailsに表示された情報
The app “NeneShogiSwift” has been killed by the operating system because it is using too much memory.
Domain: IDEDebugSessionErrorDomain
Code: 11
Recovery Suggestion: Use a memory profiling tool to track the process memory usage.
User Info: {
DVTErrorCreationDateKey = "2024-04-27 09:06:42 +0000";
IDERunOperationFailingWorker = DBGLLDBLauncher;
}
--
The app “NeneShogiSwift” has been killed by the operating system because it is using too much memory.
Domain: IDEDebugSessionErrorDomain
Code: 11
Recovery Suggestion: Use a memory profiling tool to track the process memory usage.
User Info: {
IDERunOperationFailingWorker = DBGLLDBLauncher;
}
--
Event Metadata: com.apple.dt.IDERunOperationWorkerFinished : {
"device_isCoreDevice" = 1;
"device_model" = "iPhone16,1";
"device_osBuild" = "17.4.1 (21E236)";
"device_platform" = "com.apple.platform.iphoneos";
"dvt_coredevice_version" = "355.24";
"dvt_mobiledevice_version" = "1643.100.58";
"launchSession_schemeCommand" = Run;
"launchSession_state" = 2;
"launchSession_targetArch" = arm64;
"operation_duration_ms" = 418658;
"operation_errorCode" = 11;
"operation_errorDomain" = IDEDebugSessionErrorDomain;
"operation_errorWorker" = DBGLLDBLauncher;
"operation_name" = IDERunOperationWorkerGroup;
"param_debugger_attachToExtensions" = 0;
"param_debugger_attachToXPC" = 1;
"param_debugger_type" = 3;
"param_destination_isProxy" = 0;
"param_destination_platform" = "com.apple.platform.iphoneos";
"param_diag_MainThreadChecker_stopOnIssue" = 0;
"param_diag_MallocStackLogging_enableDuringAttach" = 0;
"param_diag_MallocStackLogging_enableForXPC" = 1;
"param_diag_allowLocationSimulation" = 1;
"param_diag_checker_tpc_enable" = 1;
"param_diag_gpu_frameCapture_enable" = 0;
"param_diag_gpu_shaderValidation_enable" = 0;
"param_diag_gpu_validation_enable" = 0;
"param_diag_memoryGraphOnResourceException" = 0;
"param_diag_queueDebugging_enable" = 1;
"param_diag_runtimeProfile_generate" = 0;
"param_diag_sanitizer_asan_enable" = 0;
"param_diag_sanitizer_tsan_enable" = 0;
"param_diag_sanitizer_tsan_stopOnIssue" = 0;
"param_diag_sanitizer_ubsan_stopOnIssue" = 0;
"param_diag_showNonLocalizedStrings" = 0;
"param_diag_viewDebugging_enabled" = 1;
"param_diag_viewDebugging_insertDylibOnLaunch" = 1;
"param_install_style" = 0;
"param_launcher_UID" = 2;
"param_launcher_allowDeviceSensorReplayData" = 0;
"param_launcher_kind" = 0;
"param_launcher_style" = 99;
"param_launcher_substyle" = 8192;
"param_runnable_appExtensionHostRunMode" = 0;
"param_runnable_productType" = "com.apple.product-type.application";
"param_structuredConsoleMode" = 1;
"param_testing_launchedForTesting" = 0;
"param_testing_suppressSimulatorApp" = 0;
"param_testing_usingCLI" = 0;
"sdk_canonicalName" = "iphoneos17.4";
"sdk_osVersion" = "17.4";
"sdk_variant" = iphoneos;
}
--
System Information
macOS Version 14.4.1 (Build 23E224)
Xcode 15.3 (22618) (Build 15E204a)
Timestamp: 2024-04-27T18:06:42+09:00
要するにメモリ使いすぎ。
この実験の時、USI_Hashは256(MB)に設定されていた。 ponderの時間が6分でクラッシュしている。通常の対局では、お互いが15分ずつ使ってもクラッシュしないので、評価関数を呼び出すごとに発生するメモリリークとは異なると考えられる。
ponder思考時間と、メモリ使用量 15s 452MB 45s 741MB 300s 2.94GB 消費メモリ4~5GBの間でクラッシュした。
YaneuraOu/source/engine/dlshogi-engine/dlshogi_searcher.h
より
// エンジンオプションの "UCT_NodeLimit" の値。
// これは、Nodeを作る数の制限。これはメモリ使用量に影響する。
// 探索したノード数とは異なる。
// ※ 探索rootでの訪問回数(move_count)がこれを超えたらhashfullとして探索を中止する。
NodeCountType uct_node_limit;
UCT_NodeLimit= 10000000
がデフォルトで設定されていた。
USI_Hashではなく、この値を下げることが必要。
https://tech-blog.optim.co.jp/entry/2022/10/26/080000 OSで確保できるメモリを取得できる方法もあるようだが、swapも含むようで、swapされると困る。
ここでは単純に定数で決定することにする。 今回の実験では、ハッシュ使用率が16%でクラッシュしていた。issue先頭では、hashfull=90 (90/1000)でクラッシュしていた。手数が進んでいるので、GUIなどがメモリを取る分もあると考えられる。 安全を見て、hashfull=50を限界として処理する。設定値は500000となる。
UCT_NodeLimit=500000で、上限に達したら安全に停止。
ponderが終わったら思考開始できる。
相手が234秒長考している間にクラッシュした。なぜクラッシュしたのかまではわからない。 http://wdoor.c.u-tokyo.ac.jp/shogi/view/2024/04/27/wdoor+floodgate-300-10F+neneiphone15pro+Gihou_Ryzen7-3700X+20240427163010.csa