-
Notifications
You must be signed in to change notification settings - Fork 664
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
Minify library size #157
Comments
Latest researches:
So,the library size can be reduced up to 310kb. |
Done: Starting point (after uglifyJS) = 422Kb
Current size of the library: 322kb |
Anything new on getting deper into the closure flags? Would be good for the size of the lib to get to use the force of ADVANCED_OPTIMIZATIONS https://developers.google.com/closure/compiler/docs/compilation_levels?csw=1 Are we using closure today? When I run i on 0.1.7 I get the following errors
|
Due some problems I temporary turn off Closure Compiler until we finish Let we spend this week with manuals and documentation (I think we need to 2015-06-01 15:12 GMT+03:00 Mathias Rangel Wulff notifications@github.com:
|
All of them can be solved, it simply reqires time. Unfortunately, currently we can not use ADVANCED OPTIMIZTAION, because 2015-06-01 15:12 GMT+03:00 Mathias Rangel Wulff notifications@github.com:
|
Sure - its not on the roadmap for now - just want to keep the fire going :) Input for 300K
If we get more extream on size we can try to look into the following - but we must do tests to make sure it does not affect speed
(thinking here if its an idea to have a production version and a dev version where the dev gives nice errors from correct line and prod only provides an error code) (also having excel as module would remove the template strings from the core) |
Cool! You can look at the |
If we rename |
Good! We can call it .JS? Отправлено с iPhone
|
sure. Ill rename .toJavaScript to .JS in src files |
Ok Отправлено с iPhone
|
Renaming to .JS kept giving errors and I could not identify where the issue came from - so its .toJS until we look at it again. Please pull changes from develop. |
Minor changes in the code and with language set to ECMASCRIPT5 I got closure to compile in advanced mode. Its 307.75 kB ( .min version is at the moment 437.271 kB) Will run the tests on the code to verify if things still work I have a feeling we need more work before tests will be OK. If we start using closure its important with correct use of comments to document the functions as Closure uses this to typecheck https://developers.google.com/closure/compiler/docs/js-for-compiler?csw=1#types |
Unfortunately, this flag kills the parser. We have the option to change something in the parser code to prevent this overoptimization. |
We could also have the parser as external while closure parsing and bundling it up afterwards - so we have kind of a stub in the code and then replace it after |
Is there a way to make the full library "tree shaking"? |
@noid2 Nope. It wont work work treeshare because one third of the code is the parser of SQL and the other third builds costum functions that are eval'ed to use the last third of the code. Its a bit of a bummer... |
@agershun have you ever considered building the functions into strings and exporting the strings to the executable functions - so people could use only the compiled version of the functions they need? |
The parser is about half the library. It could be worth looking into using https://sap.github.io/chevrotain/ The grammar is is another format so might be a risky job to swap over. Its about 8x as fast as the JISON parser - Would be interesting to see if this actually is worth it as the parsing of sql is often not the thing that takes time. Nice sandpit: https://sap.github.io/chevrotain/playground/ |
I spent some time studying the source code and my conclusion is that its about time to start building a new major version from scratch. ps. I come from data science (10+years) and I am not a professional developer but I have fallen in love with JavaScript for the past 4 years :) |
Hi @noid2 You are welcome to come and join. Taking the lead on next version would be very helpful. Some work have been put into converting the current base to modules - the first step to get the code modernized. If you feel an approach from scratch is helpful we are open to that, but its a lot of work. As I see it the best aproach would be to make a tiny version only with select and simple functions that can can have more functionality added to it. The nasty part is the paser. almost half of the size - and most people dont use much of that any more. Another aproach would be to handle alasql functions at build time - a bit like svelte - where the actual code to do the magic is generated so no parser or alasql is needed in production letting alasql basically become a codegenerator. (it is a code generator now under the hood) What approach have you been considering? |
Hi @mathiasrw Its nice that you agree on a new version. The current version is really awesome and packed with features. Of course there are some bugs but it gets the job done. What I think is truly unique is the ability to use query JSON data with SQL and use SQL, AlaSQL and JS functions while selecting. That's the best of SQL and JS words combined. PostgreSQL has similar functionality but its not as natural as AlaSQL. My idea is to have have a core high performance library that solves the core problem of querying data using SQL in the JS world. This can be achieved by first making one "standard" and following it.
I know this looks overwhelming, but its not so much compare to the efforts put in maintaining the current version. Also, when I say "from scratch" it does not mean to write again every bit of code, it means to use as much as possible from existing code. I suggest that the starting point would be to strip down the current version and remove everything except of the select feature. I have already tried this but the parser (its big, obviously) but for me is very confusing. I do not understand much of it. Of course there are many other details to discuss. |
Current size of the library slowly grows, because we add new features. Probably, it is a time to compress the code with more radical tools than UglifyJS:
alasql.databases
toaq.db
The text was updated successfully, but these errors were encountered: