emscripten-core/emscripten

PATH.normalize is incredibly expensive.

オープン

#16,858 opened on 2022/05/02

 (8 件のコメント) (0 件のリアクション) (0 人の担当者)C++ (3,519 件のフォーク)batch import
good first bughelp wanted

Repository metrics

Stars
 (27,361 個のスター)
PR merge metrics
 (PR metrics pending)

説明

I profiled a WebGL Unity game that had analytics enabled, and by far the most expensive call chain was PATH.normalize and related, in particular because of the .join("/") call. Just replacing the body of normalize with if(path[0] === "/" && path[1] === "/") return path.slice(1); return path; fixed the constant stutters that I was looking at. I cannot stress enough how much of a performance increase this was. Checking if the string is already normalized should help immensely.

I'm sorry I don't have any hard statistics ready for you, but just profiling any Unity game that has frequent virtual FS access (as with Unity's analytics enabled) with the Firefox Profiler should show it immediately.

I'm unsure what version of Emscripten was used in the game I profiled, but PATH.normalize is completely unchanged relative to now.

コントリビューターガイド