danvk / source-map-explorer

Analyze and debug space usage through source maps
Apache License 2.0
3.82k stars 100 forks source link

Version 2.2 too slow #158

Closed apocalyp0sys closed 4 years ago

apocalyp0sys commented 4 years ago

Description Report generation takes too long on windows after version 2.2.0

Steps to reproduce

> npx source-map-explorer@2.2.2 dist/*-es2015.*.js | gnomon
Total   462.7926s
>npx source-map-explorer@2.1.2 dist/*-es2015.*.js | gnomon
Total   6.6806s

Files to reproduce Unfortnately can't share my bundle, will try to provide minimal example if this is hard to reproduce. The bundle is an angular-cli application, a set of files ~5.2Mb total, minified js with links to .map files in the same directory.

Expected behavior Should parse bundle and generate report fast, as in previous versions

Environment

jackric commented 4 years ago

I have similar orders-of-magnitude slowdown. Can't provide my bundles, but sizes are:

-rw-rw-r-- 1 jack jack 525K Jan 21 17:20 main.js
-rw-rw-r-- 1 jack jack 2.6M Jan 21 17:20 main.js.map

Environment

diniska commented 4 years ago

It is very slow on macOS either. File sizes:

-rw-r--r--  1 diniska  staff  3251044 Jan 23 22:51 2.806cfc57.chunk.js
-rw-r--r--  1 diniska  staff     1506 Jan 23 22:51 2.806cfc57.chunk.js.LICENSE
-rw-r--r--  1 diniska  staff  2997800 Jan 23 22:51 2.806cfc57.chunk.js.map
-rw-r--r--  1 diniska  staff    59610 Jan 23 22:51 main.d5e2cfc4.chunk.js
-rw-r--r--  1 diniska  staff   125445 Jan 23 22:51 main.d5e2cfc4.chunk.js.map
-rw-r--r--  1 diniska  staff     1549 Jan 23 22:51 runtime-main.213bd834.js
-rw-r--r--  1 diniska  staff     8268 Jan 23 22:51 runtime-main.213bd834.js.map

It is fast enough for all the files from the list except 2.806cfc57.chunk.js. Also, I use typescript, and the old version of the source-map-explorer (2.1.2) shows half of this file as [no source]. I'd be fine with the older version, but completely not sure what this [no source] means.

kevin-ashton commented 4 years ago

Also having the same problem on Mac with 2.2.2. Took 5 minutes. With 2.1.2 basically was instant. I can provide an example files if needed.

miku86 commented 4 years ago

I'm having the same problem on Linux.

Linux: 5.4.15-arch1-1 Node: 13.7.0 Create-React-App with TypeScript 3.7.5

Link to repo

I tested different versions of source-map-explorer and as we can see, 2.2.0 introduced the problems for me. From 5s to 10min.

npx source-map-explorer@2.1.2 build/static/js/*.js | gnomon
Unable to map 207/3280888 bytes (0.01%)
Unable to map 149/48429 bytes (0.31%)
Unable to map 13/1597 bytes (0.81%)
  4.6544s   build/static/js/2.d7aa2ef4.chunk.js
  0.0007s   build/static/js/main.9111df4f.chunk.js
  0.2300s   build/static/js/runtime-main.ddde9e8a.js
  0.0004s   
Total   4.8865s
npx source-map-explorer@2.2.0 build/static/js/*.js | gnomon
Unable to map 207/3280888 bytes (0.01%)
Unable to map 149/48429 bytes (0.31%)
Unable to map 13/1597 bytes (0.81%)
594.2438s   build/static/js/2.d7aa2ef4.chunk.js
  0.0007s   build/static/js/main.9111df4f.chunk.js
  0.6000s   build/static/js/runtime-main.ddde9e8a.js
  0.0004s   
Total   594.8463s
npx source-map-explorer@2.2.2 build/static/js/*.js | gnomon
Unable to map 207/3280888 bytes (0.01%)
Unable to map 149/48429 bytes (0.31%)
Unable to map 13/1597 bytes (0.81%)
554.1818s   build/static/js/2.d7aa2ef4.chunk.js
  0.0007s   build/static/js/main.9111df4f.chunk.js
  0.2438s   build/static/js/runtime-main.ddde9e8a.js
  0.0004s   
Total   554.4285s
danvk commented 4 years ago

@nikolay-borzov Should we revert? I wonder if there's some kind of N^2 behavior going on with this change: https://github.com/danvk/source-map-explorer/commit/9c3195d2e01d2876b9aa2ca31c8e70c1389c5c3b#diff-217996167f456ef6ed8c3fd188b5c188R8

nikolay-borzov commented 4 years ago

Please use version 2.1.2. I suppose slowness is caused by size calculation logic changes. Instead of counting columns count SME calculates text string bytes size. We need to find the place in code with biggest impact.

miku86 commented 4 years ago

All right, thanks! I created a branch, so that you have a snapshot, perhaps this can help you to find the problem. Branch

South-Paw commented 4 years ago

I was convinced something was wrong with out code or bundles but I ended up downgrading to 2.1.2 and everything just worked fine again...

sebastijandumancic commented 4 years ago

Yup, can confirm, still too slow to even wait for the end. 2.1.2 is instant. macOs 10.15.2