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

Universal backend: Implement a tree shaker to create small applications #246

Open
feeley opened this issue Apr 25, 2017 · 1 comment
Open

Comments

@feeley
Copy link
Member

feeley commented Apr 25, 2017

Estimated time: 40 hours

Currently the compiler isn't very smart when linking an application. Ideally, only the library code that is relevant to the application should be kept in the generated application.

To achieve this, the compiler and linker can do a reachability analysis to determine which procedure definitions are "reachable" (called) from top-level expressions and also other reachable procedures.

This is rather easy to implement, but it will not give good results as-is because of how the runtime library is written. If we think of exception handling, currently the runtime system will check a run time flag to see if a REPL should be started. Given that even a tiny program might raise exceptions (for example + applied to non-numbers), the implementation of the repl (procedure ##repl) is always reachable, and consequently so is the procedure eval, the reader, the printer, the I/O subsystem, etc. Basically nothing can be eliminated because eval can access anything dynamically.

So for the most part, to achieve the goal of small applications, it is necessary to rethink the organisation of the runtime library with tree shaking in mind.

@feeley
Copy link
Member Author

feeley commented Jul 6, 2017

Just a quick observation that the "import" statements generated by some targets should be turned into features so that they are only included if really necessary. This will help reduce load time and memory footprint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant