designcourse icon indicating copy to clipboard operation
designcourse copied to clipboard

⚡️ reduce bundle size by trimming `pako`

Open BenoitZugmeyer opened this issue 1 year ago • 5 comments
trafficstars

Motivation

This PR reduces the RUM bundle size by trimming the pako embedded in our codebase.

  • pako is a library implementing zlib in JS. pako/zlib provides some features and customizations that we don't use. This PR removes some of those features.

  • the pako build that we copied have some unnecessary verbose syntax, like relying on properties for constants (ex: constants.Z_SYNC_FLUSH = xxx, minified as x.Z_SYNC_FLUSH=xxx) instead of using manglable variable declarations (var Z_SYNC_FLUSH = xxx, minified as var x=xxx)

Changes

  • remove support for options level, windowBit, dictionary, header and gzip, and associated code
  • some syntaxic changes

Please review commit by commit.

Testing

  • [x] Local
  • [ ] Staging
  • [ ] Unit
  • [ ] End to end

I have gone over the contributing documentation.

BenoitZugmeyer avatar Jul 19 '24 14:07 BenoitZugmeyer

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum 161.62 KiB 153.59 KiB -8225 B -4.97%
Logs 57.95 KiB 57.95 KiB 0 B 0.00%
Rum Slim 110.14 KiB 110.14 KiB 0 B 0.00%
Worker 25.21 KiB 17.17 KiB -8225 B -31.87%
🚀 CPU Performance
Action Name Base Average Cpu Time (ms) Local Average Cpu Time (ms) 𝚫
addglobalcontext 0.001 0.002 0.001
addaction 0.030 0.053 0.023
adderror 0.031 0.038 0.007
addtiming 0.001 0.001 0.000
startview 0.913 1.411 0.498
startstopsessionreplayrecording 0.780 1.011 0.231
logmessage 0.019 0.023 0.004
🧠 Memory Performance
Action Name Base Consumption Memory (bytes) Local Consumption Memory (bytes) 𝚫 (bytes)
addglobalcontext 20.46 KiB 19.59 KiB -889 B
addaction 72.73 KiB 70.35 KiB -2443 B
adderror 86.60 KiB 85.91 KiB -704 B
addtiming 19.47 KiB 17.79 KiB -1714 B
startview 349.22 KiB 351.36 KiB 2.14 KiB
startstopsessionreplayrecording 14.21 KiB 12.46 KiB -1796 B
logmessage 70.55 KiB 69.00 KiB -1583 B

🔗 RealWorld

cit-pr-commenter[bot] avatar Jul 19 '24 14:07 cit-pr-commenter[bot]

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 93.67%. Comparing base (2490414) to head (dda2fb5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2878      +/-   ##
==========================================
- Coverage   93.68%   93.67%   -0.02%     
==========================================
  Files         266      266              
  Lines        7584     7584              
  Branches     1687     1687              
==========================================
- Hits         7105     7104       -1     
- Misses        479      480       +1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Jul 19 '24 14:07 codecov-commenter

/to-staging

BenoitZugmeyer avatar Jul 25 '24 12:07 BenoitZugmeyer

:steam_locomotive: Branch Integration: starting soon, median merge time is 12m

Commit dda2fb5ab9 will soon be integrated into staging-30.

Use /to-staging -c to cancel this operation!

dd-devflow[bot] avatar Jul 25 '24 12:07 dd-devflow[bot]

:steam_locomotive: Branch Integration: This commit was successfully integrated

Commit dda2fb5ab9 has been merged into staging-30 in merge commit 0c0bbb7fdc.

Check out the triggered pipeline on Gitlab :fox_face:

dd-devflow[bot] avatar Jul 25 '24 13:07 dd-devflow[bot]