5 ms·
Lightening run-time code generation
- chrisseaton 7y agoGuile is a really interesting story in that they've spent ages doing some fantastic optimisations, of the kind you usually don't do when your final execution engine is just an interpreter. I used to read Andy's blog posts about compilers unaware that the pipeline didn't actually end in machine code. Hopefully that makes the template JIT they have here enough to get good performance as the input should already be in really good shape. I wonder why Andy didn't chose to write the JIT in Guile itself, with a binding to Lightening, rather than in C. Guile is designed to be embedded and have bindings written for it.
- jlg23 7y ago> I wonder why Andy didn't chose to write the JIT in Guile itself, with a binding to Lightening, rather than in C. Guile is designed to be embedded and have bindings written for it. OP states "eventually I should be migrating this code over to Scheme anyway. And, of course, simple can mean fast, and I needed fast code generation.". That does not anwer you actual question (and neither does the article), but I gather this was to make the project finite (solve one and only one problem only at a time), not because the author was not aware.
- chrisseaton 7y agoYes that’s the statement I’m responding to “I didn't want to add more complexity to the C side of Guile“ but this is more C code. Maybe speed of generation was more important than anything else then.
- bjoli 7y agoWhat I love about the guile optimizer (and some lisp optimizers in general) is that you usually have a first step of source to source optimization. That means I can write some code and see what gets inined, hoisted, unrolled and removed without having to read the bytecode assembly. That is especially nice when writing complex macros. I remember writing a loop utility and realized I couldn't run the optimizer on code where everything was known at compile time, since guile usually optimized the loop away. (for/sum ((i (in-range 5)) i) expanded into 20 lines of code, but optimized to the integer 15 :)
- chrisseaton 7y agoThe tricky think about a source-to-source transformation, is where do you store the meta-data to map the new source back to the old source, for the purposes of error reporting, debugging, and deoptimisation? You can't just map from one list to another as your optimisation function.
- bjoli 7y agoI think it is the same system as used when doing macro expansion. Macros use syntax objects with embedded metadata. Both chez and guile usually produces proper error sites, so it is done in some fashion.
- ncmncm 7y agoIt makes me obscurely happy to see Guile evolving to remain useful, despite my misgivings about obligate-GC languages in general.
- stcredzero 7y agodespite my misgivings about obligate-GC languages in general In terms of performance, you have a point. However, there are many ways to set the performance dial, depending on your particular cost/benefit situation.
- neilv 7y agoAm building Guile 2.9.2 right now, to try it out. When Racket (nee PLT Scheme) added JIT on x86, via GNU Lightning, there was a very noticeable practical performance bump for some of my work (dynamic Web serving).
- bjoli 7y agoFor 2.9.1 I saw a performance improvement of between 1.5 and 4x across all workloads. It is still not as fast as racket, but iirc Andy said there are some low hanging fruit left. The peg parser and my implementatio of clojure's transducers get the biggest performance improvements. My simple CSV parser got over 3x faster without any changes on my part.
- fatcow 7y agoHi! I'm struggling to lean peg in guile - care to share csv-parsing code please?
- bjoli 7y agoSure. Ill put it online whenever I have access to my computer next. Are you in #guile on freenode? Ivan ping you there when it's up. It is slow as molasses though. A 5mb CSV file takes roughly 12s on 2.2. A properly implemented streaming parser should be several orders of magnitude faster. I want to see, just for shits and giggles if it is possible to beat pythons CSV parser with a pure guile module. I think it is. With guile 2.9 it should be a walk in the park.
- neilv 7y agoI have a CSV parser that was originally portable R5RS+SRFI, and probably still is given minor editing. I don't know how the performance compares. (Paying work has had me focused on Racket, so I stopped doing portable packagings, but I might be going back to releasing portable packagings in R7RS.) https://www.neilvandyke.org/racket/csv-reading/ https://www.neilvandyke.org/racket/csv-reading/
- 7y ago
- peetle 7y agoLightening /= lightning
- fithisux 7y ago"It's written in C and not C++" hope to stay this way. I really like guile. My problem is that I am on windows.