emscripten-core / emscripten-core/emscripten
PATH.normalize is incredibly expensive.
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 109
Description
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.
Contributor guide
Assessment
This issue has not been assessed yet.