diff --git a/LINKS.md b/LINKS.md deleted file mode 100644 index 010b4ba..0000000 --- a/LINKS.md +++ /dev/null @@ -1,28 +0,0 @@ -# TODO sort and organize - -## Typescript stuff - -runs queries on top of ts ast -https://github.com/phenomnomnominal/tsquery - - -a resource to manipulate typescript code on a higher level -https://github.com/JoshuaKGoldberg/TypeStat - - -description of ts internals -https://basarat.gitbook.io/typescript/overview - - -practicle example how to create a ts program in memory (and use it) -https://convincedcoder.com/2019/01/19/Processing-TypeScript-using-TypeScript/ - - -how to write transformers (handbook) -https://github.com/madou/typescript-transformer-handbook - -typescript wiki -https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API - - -https://v8.dev/blog/fast-properties \ No newline at end of file diff --git a/README.md b/README.md index 301a107..f8f45f5 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,13 @@ elm-optimize Main.elm --output app.js **Note** — elm-optimize only generates a js file, it doesn't support generating HTML. -**Another Note** — Before deploying your app, you should also minify it and gzip it. `elm-optimize` does not do that for you. [Check out this doc for a recommended setup.](minification.md) +**Another Note** — Before deploying your app, you should also minify it and gzip it. `elm-optimize` does not do that for you. [Check out this doc for a recommended setup.](notes/minification.md) ## What's actually happening? This might seem a bit like magic. :sparkles: -If you're interested in getting to know what's happening, [here's an overview of all the JS transformations we are exploring](transformations.md)! +If you're interested in getting to know what's happening, [here's an overview of all the JS transformations we are exploring](notes/transformations.md)! Not all of them are included in the CLI tool because not all of them turned out to be beneficial. Part of this endeavor is a science project :bowtie:, where we capture data so we can know which transformations turn out to be worthwhile. @@ -70,25 +70,29 @@ Though here are a few highlights: **Note** — keep in mind that these numbers have _all the caveats_ that benchmarks usually have. You may not see similar numbers depending on your machine, your browser, subtle differences in your code, etc. -**Another Note** — From what we've seen, given that you're [minifying and gzipping your JS](minification.md), these transformations should either have no effect on asset size, or may even make your app slightly smaller. +**Another Note** — From what we've seen, given that you're [minifying and gzipping your JS](notes/minification.md), these transformations should either have no effect on asset size, or may even make your app slightly smaller. ## Html | Name | Transformtions | Browser | Ops/Second | % Change | | --------------------------------- | -------------- | ------- | ---------- | -------- | -| create a 4 level nested html tree | baseline | firefox | 19,878 | | -| create a 4 level nested html tree | optimized | firefox | 24,878 | (125%) | -| create a 4 level nested html tree | baseline | chrome | 43,689 | | -| create a 4 level nested html tree | optimized | chrome | 113,266 | (259%) | +| create a 4 level nested html tree | | safari | 34,899 | | +| create a 4 level nested html tree | final | safari | 39,631 | (114%) | +| create a 4 level nested html tree | | firefox | 15,909 | | +| create a 4 level nested html tree | final | firefox | 22,361 | (141%) | +| create a 4 level nested html tree | | chrome | 28,959 | | +| create a 4 level nested html tree | final | chrome | 72,753 | (251%) | ## Elm Markdown | Name | Transformtions | Browser | Ops/Second | % Change | | ------------------------- | -------------- | ------- | ---------- | -------- | -| dillonkearns/elm-markdown | baseline | firefox | 1,226 | | -| dillonkearns/elm-markdown | optimized | firefox | 2,497 | (204%) | -| dillonkearns/elm-markdown | baseline | chrome | 3,116 | | -| dillonkearns/elm-markdown | optimized | chrome | 5,099 | (164%) | +| dillonkearns/elm-markdown | | safari | 2,428 | | +| dillonkearns/elm-markdown | final | safari | 3,196 | (132%) | +| dillonkearns/elm-markdown | | firefox | 1,096 | | +| dillonkearns/elm-markdown | final | firefox | 2,194 | (200%) | +| dillonkearns/elm-markdown | | chrome | 2,489 | | +| dillonkearns/elm-markdown | final | chrome | 3,572 | (144%) | ## Running Benchmarks Locally @@ -104,14 +108,22 @@ _For this project, contributions always start with communication before code!_ That being said, there are a few areas that might be opportunities for contribution. -**First and formost** is to try `elm-optimize` on any current Elm project you have. +1. Try `elm-optimize` on any current Elm project you have! -We'd love to hear your results whether they be success, no effect, or caused a regression. + We'd love to hear your results whether they be success, no effect, or caused a regression. -If your project saw an explicit improvement or performance regression, [leave a comment on this issue](https://github.com/mdgriffith/elm-optimize/issues/15). + If your project saw an explicit improvement or performance regression, [leave a comment on this issue](https://github.com/mdgriffith/elm-optimize/issues/15). -For more serious issues, feel free to file a separate issue. + For more serious issues, feel free to file a separate issue. -**Secondly**, if you believe there are public benchmarks that we could track that are _not essentially covered_ by our current benchmarks, let us know! We want the benchmarking suite to be as comprehensive as possible, though we have to weigh that against having a million benchmarks that essentially test the same thing. +2. Are there more interesting benchmarks we could track? -**Thirdly**, if you believe there are additional JS transformations that would be interesting to explore, or would like to try improving existing transformations in some way, get in touch! + We want the benchmarking suite to be as comprehensive as possible, though we have to weigh that against having a million benchmarks that essentially test the same thing. + +3) Know of an interesting transformation to try out? + + Let us know! Either open an issue, or make a PR adding it to [notes/transformations.md](notes/transformations.md). + +4. Know of an article, paper, or project we might be interested in? + + Let us know! We're keeping a list of relevant resources in [notes/resources.md](notes/resources.md) diff --git a/minification.md b/notes/minification.md similarity index 51% rename from minification.md rename to notes/minification.md index abbb73c..a0fe1dd 100644 --- a/minification.md +++ b/notes/minification.md @@ -1,5 +1,7 @@ # Minification +We're basically following the same protocol as [described on the Elm Guide.](https://guide.elm-lang.org/optimization/asset_size.html) We use Terser, which is just an actively maintained fork of Uglify. + After installing `elm-optimize`, Install a minifier like [`Terser`](https://www.npmjs.com/package/terser). @@ -12,9 +14,9 @@ Then, you'll want to run these commands to minify and gzip your code before depl ```bash elm-optimize Main.elm --output=app.js -terser app.js +terser app.js --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters,keep_fargs=false,unsafe_comps,unsafe' | terser --mangle --output=app.min.js gzip --keep --force app.min.js # --keep = keep the original file # --force = overwrite the exisign gzip file if it's there -``` \ No newline at end of file +``` diff --git a/notes/resources.md b/notes/resources.md new file mode 100644 index 0000000..ed24046 --- /dev/null +++ b/notes/resources.md @@ -0,0 +1,31 @@ +# Resources + +## Javascript Performance + +_These are resources that discuss specifics about what matters for Javascript performance._ + +[Robin's article on exploring improving Elm's compilter output](https://dev.to/skinney/improving-elm-s-compiler-output-5e1h) + +[Fast Properties in V8](https://v8.dev/blog/fast-properties) + +[What's up with Monomorpism](https://mrale.ph/blog/2015/01/11/whats-up-with-monomorphism.html) + +## Transforming JS code + +_Here are resources that are concerned with querying and transforming Javascript code._ + +[Running queries on top of the Typecript AST.](https://github.com/phenomnomnominal/tsquery) + +[Manipulating typescript code on a higher level.](https://github.com/JoshuaKGoldberg/TypeStat) + +[A description of TypeScript internals.](https://basarat.gitbook.io/typescript/overview) + +[A practical example of how to create a TS program in memory and use it.](https://convincedcoder.com/2019/01/19/Processing-TypeScript-using-TypeScript/) + +[The Handbook on how to write Javascript transformers.](https://github.com/madou/typescript-transformer-handbook) + +[The Typescript wiki](https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API) + +## Research + +[Description of VLists](https://infoscience.epfl.ch/record/52465/files/IC_TECH_REPORT_200244.pdf) diff --git a/transformations.md b/notes/transformations.md similarity index 96% rename from transformations.md rename to notes/transformations.md index 6aad49b..c08c53e 100644 --- a/transformations.md +++ b/notes/transformations.md @@ -141,10 +141,11 @@ This does require information from the Elm code itself, which we're currently ge ## Results Summary -- Included +- Partially Included - We stub in shapes for `Maybe` and `List`, but that's it. - Has an effect in certain circumstances in browsers using V8(Chrome and Edge). Nothing observable otherwise. - Most prominently observed in the `Elm Core - sum 300 list of custom types` benchmark. Otherwise I didn't notice it. - No noticable effect on asset size. +- More work is needed to make parsing an existing project more robust and also to discover what approach for representing the shapes actually produces the best benefit. # Inlining literal list constructors @@ -374,3 +375,9 @@ This is when you add or remove anonymous functions: `map (f x y) zs` to `map (\z -> f x y z) zs` Because of our previous optimizations where we can call a function directly, this can make sure we're getting the fast version of `f`! + +# Tail Recursion Modulo Cons + +Whew, what a name! I feel like this should be my DJ name in the future. + +In Elm