emscripten-core/emscripten

PATH.normalize is incredibly expensive.

Open

#16,858 创建于 2022年5月2日

在 GitHub 查看
 (8 评论) (0 反应) (0 负责人)C++ (27,361 star) (3,519 fork)batch import
good first bughelp wanted

描述

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.

贡献者指南

PATH.normalize is incredibly expensive. · emscripten-core/emscripten#16858 | Good First Issue