Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List of premature optimizations #31

Open
elimirks opened this issue Sep 7, 2021 · 0 comments
Open

List of premature optimizations #31

elimirks opened this issue Sep 7, 2021 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@elimirks
Copy link
Member

elimirks commented Sep 7, 2021

Pass small ADTs by value

We can probably be clever with allocations for ADTs with few parameters. As in, pass them by value rather than allocate memory for all of them. A Maybe or Either type takes up a trivial amount more memory than whatever it contains, so it's probably worth just copying it instead of returning a reference or passing a reference to a function.

If all elements in an ADT only have 1 data slot, pass them by value instead of reference

If a closure environment doesn't contain non root references, make it a function

In version 1 of the compiler we're just making everything a closure, which is a bit pointless for functions that only have root level references

Try to store lists contiguously

The V1 allocator will be pretty dumb with lists, slotting them wherever possible. To utilize the cache better, we should try to store lists in contiguous memory.

Extending onto this, if you map over a list, it can trivially be given a contiguous memory block

Cache compiled library code

Instead of recompiling the entire stdlib for every program, cache the compiled libraries

Use TrieMap to prune redundant expressions and function definitions

@elimirks elimirks added the documentation Improvements or additions to documentation label Sep 7, 2021
@elimirks elimirks changed the title Some optimization ideas List of premature optimizations Sep 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant