Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

refactor(formatter): Use slice to store content #2775

Merged
merged 2 commits into from
Jun 24, 2022

Conversation

MichaReiser
Copy link
Contributor

@MichaReiser MichaReiser commented Jun 24, 2022

Summary

This PR changes the Content type alias for FormatElement from Box<FormatElement> to Box<[FormatElement]>.

The main motivation behind this is that VecBuffer always allocates a new vector even if only one element was written. Instead of discarding this vector and then boxing the element this PR uses vec.into_boxed_slice that avoids the additional allocation.

Dhat numbers:

Formatted
	Memory
		Current Blocks: 63751 -> 57091
		Current Bytes: 6.07 MB -> 5.28 MB
		Max Blocks: 63793 -> 57136
		Max Bytes: 6.08 MB -> 5.29 MB
		Total Blocks: 329404 -> 328939
		Total Bytes: 23.83 MB -> 24.87 MB
Printed (no changes, as unaffected)
	Memory
		Current Blocks: 20139
		Current Bytes: 2.75 MB
		Max Blocks: 57098
		Max Bytes: 6.57 MB
		Total Blocks: 5472
		Total Bytes: 2.58 MB

Test Plan

This PR isn't adding any new functionality.

Performance

group                                    main                                    slice
-----                                    ----                                    -----
formatter/checker.ts                     1.02    221.4±1.87ms    11.7 MB/sec     1.00    216.1±3.17ms    12.0 MB/sec
formatter/compiler.js                    1.05    141.2±8.11ms     7.4 MB/sec     1.00    135.0±1.14ms     7.8 MB/sec
formatter/d3.min.js                      1.00    110.8±3.41ms     2.4 MB/sec     1.03   114.2±19.37ms     2.3 MB/sec
formatter/dojo.js                        1.01      7.5±0.03ms     9.2 MB/sec     1.00      7.4±0.02ms     9.3 MB/sec
formatter/ios.d.ts                       1.03    150.9±0.95ms    12.4 MB/sec     1.00    147.0±5.47ms    12.7 MB/sec
formatter/jquery.min.js                  1.00     29.1±0.07ms     2.8 MB/sec     1.00     29.0±0.15ms     2.8 MB/sec
formatter/math.js                        1.00    229.5±1.36ms     2.8 MB/sec     1.01    232.9±1.46ms     2.8 MB/sec
formatter/parser.ts                      1.07      5.0±0.03ms     9.6 MB/sec     1.00      4.7±0.09ms    10.2 MB/sec
formatter/pixi.min.js                    1.02    126.0±2.88ms     3.5 MB/sec     1.00    124.0±2.83ms     3.5 MB/sec
formatter/react-dom.production.min.js    1.00     35.0±1.02ms     3.3 MB/sec     1.02     35.6±0.59ms     3.2 MB/sec
formatter/react.production.min.js        1.04  1867.1±182.20µs     3.3 MB/sec    1.00  1791.8±17.46µs     3.4 MB/sec
formatter/router.ts                      1.02      3.6±0.01ms    16.3 MB/sec     1.00      3.6±0.01ms    16.5 MB/sec
formatter/tex-chtml-full.js              1.03    300.3±1.71ms     3.0 MB/sec     1.00    292.9±1.57ms     3.1 MB/sec
formatter/three.min.js                   1.02    146.4±2.54ms     4.0 MB/sec     1.00    143.0±1.22ms     4.1 MB/sec
formatter/typescript.js                  1.01   901.4±14.89ms    10.5 MB/sec     1.00   895.9±17.75ms    10.6 MB/sec
formatter/vue.global.prod.js             1.00     46.0±0.16ms     2.6 MB/sec     1.00     45.8±0.54ms     2.6 MB/sec

@MichaReiser MichaReiser temporarily deployed to aws June 24, 2022 13:33 Inactive
@cloudflare-pages
Copy link

cloudflare-pages bot commented Jun 24, 2022

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 15f9c45
Status: ✅  Deploy successful!
Preview URL: https://3f40077f.tools-8rn.pages.dev
Branch Preview URL: https://refactor-content-to-slice.tools-8rn.pages.dev

View logs

@github-actions
Copy link

github-actions bot commented Jun 24, 2022

@MichaReiser MichaReiser temporarily deployed to aws June 24, 2022 13:45 Inactive
@github-actions
Copy link

Parser conformance results on ubuntu-latest

js/262

Test result main count This PR count Difference
Total 45878 45878 0
Passed 44938 44938 0
Failed 940 940 0
Panics 0 0 0
Coverage 97.95% 97.95% 0.00%

jsx/babel

Test result main count This PR count Difference
Total 39 39 0
Passed 36 36 0
Failed 3 3 0
Panics 0 0 0
Coverage 92.31% 92.31% 0.00%

symbols/microsoft

Test result main count This PR count Difference
Total 5946 5946 0
Passed 388 388 0
Failed 5558 5558 0
Panics 0 0 0
Coverage 6.53% 6.53% 0.00%

ts/babel

Test result main count This PR count Difference
Total 588 588 0
Passed 519 519 0
Failed 69 69 0
Panics 0 0 0
Coverage 88.27% 88.27% 0.00%

ts/microsoft

Test result main count This PR count Difference
Total 16257 16257 0
Passed 12393 12393 0
Failed 3864 3864 0
Panics 0 0 0
Coverage 76.23% 76.23% 0.00%

@MichaReiser MichaReiser temporarily deployed to aws June 24, 2022 13:51 Inactive
@MichaReiser MichaReiser requested review from leops and xunilrj and removed request for leops June 24, 2022 13:54
@MichaReiser MichaReiser temporarily deployed to aws June 24, 2022 14:22 Inactive
@MichaReiser MichaReiser merged commit cd7ae6b into main Jun 24, 2022
@MichaReiser MichaReiser deleted the refactor/content-to-slice branch June 24, 2022 14:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants