DoD에 대한 기록

전 글에도 적었지만 swc css minifier 성능 최적화를 하다가 DoD 라는 걸 알게 됐다. 힙 할당을 늘렸는데 성능이 엄청 올라간 걸 보고, ES minifier에도 적용해보고 싶어졌다. 물론 지금 당장 적용할 순 없는 게, SWC의 ES 모듈들은 다운스크림이 너무 많아서 그 정도 규모의 breaking change를 자주 만들긴 힘들다. 그리고 제일 문제인 건 이미 배포된 Wasm 플러그인들이고...

나중에 TS 4.9 지원하면서 AST 호환성 깰 때 같이 머지하려고 ES AST를 DoD를 고려하면서 바꿨고, 벤치마크에 필요한만큼만 패치를 해봤다. 벤치마크 결과는 다음과 같다.


Benchmarking es/minify/libraries/antd
Benchmarking es/minify/libraries/antd: Warming up for 3.0000 s

Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 6.2s.
Benchmarking es/minify/libraries/antd: Collecting 10 samples in estimated 6.1933 s (10 iterations)
Benchmarking es/minify/libraries/antd: Analyzing
es/minify/libraries/antd
                        time:   [620.86 ms 624.46 ms 628.66 ms]
                        change: [-22.841% -22.308% -21.758%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high mild
Benchmarking es/minify/libraries/d3
Benchmarking es/minify/libraries/d3: Warming up for 3.0000 s

Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 7.6s or enable flat sampling.
Benchmarking es/minify/libraries/d3: Collecting 10 samples in estimated 7.6350 s (55 iterations)
Benchmarking es/minify/libraries/d3: Analyzing
es/minify/libraries/d3  time:   [129.75 ms 130.21 ms 130.61 ms]
                        change: [-15.798% -15.371% -14.986%] (p = 0.00 < 0.05)
                        Performance has improved.
Benchmarking es/minify/libraries/echarts
Benchmarking es/minify/libraries/echarts: Warming up for 3.0000 s
Benchmarking es/minify/libraries/echarts: Collecting 10 samples in estimated 9.7596 s (20 iterations)
Benchmarking es/minify/libraries/echarts: Analyzing
es/minify/libraries/echarts
                        time:   [485.80 ms 487.35 ms 488.88 ms]
                        change: [-23.405% -22.989% -22.583%] (p = 0.00 < 0.05)
                        Performance has improved.
Benchmarking es/minify/libraries/jquery
Benchmarking es/minify/libraries/jquery: Warming up for 3.0000 s
Benchmarking es/minify/libraries/jquery: Collecting 10 samples in estimated 6.5932 s (165 iterations)
Benchmarking es/minify/libraries/jquery: Analyzing
es/minify/libraries/jquery
                        time:   [39.674 ms 39.790 ms 39.888 ms]
                        change: [-7.4199% -6.9714% -6.5607%] (p = 0.00 < 0.05)
                        Performance has improved.
Benchmarking es/minify/libraries/lodash
Benchmarking es/minify/libraries/lodash: Warming up for 3.0000 s
Benchmarking es/minify/libraries/lodash: Collecting 10 samples in estimated 6.2038 s (110 iterations)
Benchmarking es/minify/libraries/lodash: Analyzing
es/minify/libraries/lodash
                        time:   [54.658 ms 54.983 ms 55.276 ms]
                        change: [-6.0030% -5.0606% -4.3268%] (p = 0.00 < 0.05)
                        Performance has improved.
Benchmarking es/minify/libraries/moment
Benchmarking es/minify/libraries/moment: Warming up for 3.0000 s
Benchmarking es/minify/libraries/moment: Collecting 10 samples in estimated 5.5915 s (220 iterations)
Benchmarking es/minify/libraries/moment: Analyzing
es/minify/libraries/moment
                        time:   [24.989 ms 25.056 ms 25.132 ms]
                        change: [-6.9642% -6.4017% -5.7664%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high mild
Benchmarking es/minify/libraries/react
Benchmarking es/minify/libraries/react: Warming up for 3.0000 s
Benchmarking es/minify/libraries/react: Collecting 10 samples in estimated 5.0256 s (440 iterations)
Benchmarking es/minify/libraries/react: Analyzing
es/minify/libraries/react
                        time:   [11.304 ms 11.333 ms 11.348 ms]
                        change: [-4.0229% -3.4375% -2.8645%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high mild
Benchmarking es/minify/libraries/terser
Benchmarking es/minify/libraries/terser: Warming up for 3.0000 s

Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 6.3s or enable flat sampling.
Benchmarking es/minify/libraries/terser: Collecting 10 samples in estimated 6.2739 s (55 iterations)
Benchmarking es/minify/libraries/terser: Analyzing
es/minify/libraries/terser
                        time:   [113.05 ms 113.25 ms 113.53 ms]
                        change: [-14.455% -13.868% -13.346%] (p = 0.00 < 0.05)
                        Performance has improved.
Benchmarking es/minify/libraries/three
Benchmarking es/minify/libraries/three: Warming up for 3.0000 s

Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 9.4s or enable flat sampling.
Benchmarking es/minify/libraries/three: Collecting 10 samples in estimated 9.3763 s (55 iterations)
Benchmarking es/minify/libraries/three: Analyzing
es/minify/libraries/three
                        time:   [168.85 ms 169.15 ms 169.52 ms]
                        change: [-19.905% -19.348% -18.833%] (p = 0.00 < 0.05)
                        Performance has improved.
Benchmarking es/minify/libraries/typescript
Benchmarking es/minify/libraries/typescript: Warming up for 3.0000 s

Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 13.6s.
Benchmarking es/minify/libraries/typescript: Collecting 10 samples in estimated 13.646 s (10 iterations)
Benchmarking es/minify/libraries/typescript: Analyzing
es/minify/libraries/typescript
                        time:   [1.3660 s 1.3703 s 1.3747 s]
                        change: [-20.914% -20.551% -20.250%] (p = 0.00 < 0.05)
                        Performance has improved.
Benchmarking es/minify/libraries/victory
Benchmarking es/minify/libraries/victory: Warming up for 3.0000 s
Benchmarking es/minify/libraries/victory: Collecting 10 samples in estimated 5.9296 s (20 iterations)
Benchmarking es/minify/libraries/victory: Analyzing
es/minify/libraries/victory
                        time:   [290.98 ms 293.52 ms 296.23 ms]
                        change: [-16.272% -15.458% -14.495%] (p = 0.00 < 0.05)
                        Performance has improved.
Benchmarking es/minify/libraries/vue
Benchmarking es/minify/libraries/vue: Warming up for 3.0000 s
Benchmarking es/minify/libraries/vue: Collecting 10 samples in estimated 6.7515 s (110 iterations)
Benchmarking es/minify/libraries/vue: Analyzing
es/minify/libraries/vue time:   [59.382 ms 59.627 ms 59.912 ms]
                        change: [-7.4172% -6.7056% -5.9969%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high severe

3% ~ 23%면 진짜 무지막지하게 큰 숫잔데, 진짜 날로 먹은 기분이다. 지금 당장 적용할 수 있는 건 아니지만 난 DoD를 찬양하기로 했다.

글 마무리 짓는 건 항상 어려운데 그냥 내가 DoD를 공부할 때 쓴 자료들 링크 남기고 끝내겠다.

  • https://media.handmade-seattle.com/practical-data-oriented-design/
  • https://www.youtube.com/watch?v=WDIkqP4JbkE