Nathan Braswell
88a87f0760
Implement a good bit of the type inference (predicate ops, 'and', and len type inference). Need to implement combine_type_map, and figure out the structural caching
2022-06-30 00:59:04 -04:00
Nathan Braswell
4663982f1b
Move kraken,scheme,python,cpp fib tests over to koka_bench, add WAVM as a tested compiler backend for the Kraken benchmarks
2022-06-28 00:38:37 -04:00
Nathan Braswell
999d21746e
inline dup and most of drop, relative added to benchmarks, added first basic run (without any of the complex stuff implemented) of local type inference and use it to do word value equality if possible
2022-06-27 01:48:07 -04:00
Nathan Braswell
71ad070922
inline get_ptr with slightly more efficiency
2022-06-24 00:39:10 -04:00
Nathan Braswell
ae320ba31b
Most things seem to be working now, with new benchmarks. Not sure if a small memory leak is now or was there before
2022-06-23 01:00:27 -04:00
Nathan Braswell
04f3b2dbd9
Fixed static type errors, test runs now. Rbtree test has a dynamic indirect call failure, so there are still more issues to find
2022-06-22 14:04:56 -04:00
Nathan Braswell
1c3ee27547
More fixes, runs test now, but generated wasm has type errors
2022-06-22 01:43:04 -04:00
Nathan Braswell
6605050590
More bugfixes and debugging
2022-06-22 01:26:21 -04:00
Nathan Braswell
bf8d25e551
Fix a bunch of syntax errors
2022-06-22 00:46:35 -04:00
Nathan Braswell
b665877add
Finish first pass through refactoring all tagging. Need to test and bugfix
2022-06-21 23:25:04 -04:00
Nathan Braswell
b7bfc314e6
Did most of re-tagging, pick back up porting at compile
2022-06-21 02:18:06 -04:00
Nathan Braswell
dda581f839
Initial interning of symbols
2022-06-20 17:20:50 -04:00
Nathan Braswell
e77358c8b4
Merge branch 'palindrome'
2022-05-19 01:01:06 -04:00
Nathan Braswell
c7f3ee0e18
Formatting fix, end to end test run
2022-05-19 00:56:18 -04:00
Nathan Braswell
3eea883ebd
Combine benchmark tables
2022-05-19 00:49:09 -04:00
Nathan Braswell
fefae631e2
Add java ocaml and swift tests
2022-05-19 00:43:27 -04:00
Nathan Braswell
62c0958006
Added haskell versions (parameterized by CLI argument)
2022-05-18 23:59:18 -04:00
Nathan Braswell
4481784666
Update README.md
2022-05-18 05:31:43 +00:00
Nathan Braswell
a0c4eb3eaf
sigh, accidentally committed .wasm
2022-05-18 01:29:23 -04:00
Nathan Braswell
81a54b5a06
Old .gitignore actually prevent the kraken versions of the benchmarks from being comitted, scarily enough - also some of the c fib tests
2022-05-18 01:28:49 -04:00
Nathan Braswell
34c6d01c31
Implement deriv benchmark
2022-05-18 01:26:08 -04:00
Nathan Braswell
7fef7eba85
Add cfold benchmark - can't go over 5 (though Koka uses 20) because wasm runs out of stack. Not entirely sure how to handle that - I imagine we're emitting far to much on the stack frame, but also I would hope wasmtime would optimize it, and I additionally can't find a way to raise wasmtime's limit from the cli... It is worth noting that Koka notes that cfold is a benchmark that can exhaust the stack
2022-05-17 23:34:46 -04:00
Nathan Braswell
e6a1ad5bf3
Add nqueens benchmark (new kraken impl, with koka and cpp moved over from koka_bench)
2022-05-16 23:00:56 -04:00
Nathan Braswell
5ee4020c2b
Update readme to state source of koka_bench and to call out the different license for that directory
2022-05-16 02:36:30 -04:00
Nathan Braswell
b1b060292e
Moved over first rbtree test from koka_bench and integrated Kraken via compiler wrapper script that calls the partial_evaluator / compiler and then emits a wrapper script that runs the resulting wasm via wasmtime.
2022-05-16 02:33:10 -04:00
Nathan Braswell
025ca41c59
Add support for command line arguments as a monad
2022-05-16 01:35:36 -04:00
Nathan Braswell
8c773fd0d8
Add deallocation in TCE for rare-er stuff - our test doesn't actually use it yet
2022-05-14 02:20:05 -04:00
Nathan Braswell
8bc092cdeb
GAH the matching.kp was using the old broken Y combinator, fixing it makes it work. We're, uh, 682x slower than Koka
2022-05-14 01:46:53 -04:00
Nathan Braswell
6683344357
Initial implementation of TCE - doesn't properly drop params/locals, and doesn't activate for the RB-Test for some reason, but does run for the long_fact
2022-05-12 00:34:19 -04:00
Nathan Braswell
50d68c3424
Groundwork for Tail Call Elimination. Prints out when it should happen, but doesn't actually do it
2022-05-11 00:59:41 -04:00
Nathan Braswell
20c46af986
Merge branch 'master' of github.com:Limvot/kraken
2022-05-09 23:42:45 -04:00
Nathan Braswell
a966c0c0ba
Using a nice Pure Nix Flake now, implement Koka-style rb-tree test (only running on 100 instead of 42,000,000 - .06s compiled, 40m54s interpreted!!!), also a small fact to test loops - spoiler alert we need tail-call-elimination
2022-05-09 23:42:39 -04:00
Nathan Braswell
5369e58eed
Update matching.kp
2022-05-09 14:35:01 -04:00
Nathan Braswell
20d554dfe6
Fixed dropping 0-length arrays, RB-Tree seems to work well now!
2022-05-08 19:38:44 -04:00
Nathan Braswell
7e7a7c3b32
Merge branch 'master' of github.com:Limvot/kraken
2022-05-08 01:34:38 -04:00
Nathan Braswell
8dd28370c1
Ported RedBlack-Tree based on our new match. Seems to work, though compiled version crashes on memory-out-of-bounds while interpreted works - will have to debug later
2022-05-08 01:34:33 -04:00
Nathan Braswell
746933f21e
Update README.md
2022-05-07 20:19:18 +00:00
Nathan Braswell
ca68826fbc
Clean up and rearrange
2022-05-07 16:09:16 -04:00
Nathan Braswell
08c01257f3
Add matching on quoted symbols
2022-05-07 15:07:03 -04:00
Nathan Braswell
6140a7a006
Comment out un-val error message generation, was taking an absurd amount of space in final binary
2022-05-07 14:52:32 -04:00
Nathan Braswell
9bb6104952
Much more real match with arrays and unquote, also added unquote to parser and made log return its last argument
2022-05-06 00:35:31 -04:00
Nathan Braswell
c3b2a852b7
Fix debug not being called because of the function index renumbering, add calling debug for calling not a function in eval. For some reason this crashes redebug :/
2022-05-03 23:25:56 -04:00
Nathan Braswell
172512f447
Fix array inequality case
2022-05-03 22:49:50 -04:00
Nathan Braswell
2a6ee6d8e4
Fix inlineing se not being set to nil (but default 0 by wasm) so it always equaled 0
2022-05-03 22:09:37 -04:00
Nathan Braswell
d420b6491f
Fix regression - was using the wrong error when blocking recursion and treating as real error instead of stop recursion fallback
2022-04-25 09:19:14 -04:00
Nathan Braswell
223147f699
Initial inlining working - fib_let went from .4 something to .138. Suspect the remaining slowdown over fib is extra refcounting calls, but unsure. Compile error on fib_manual, need to see whether it was this change or the earlier find fixes
2022-04-25 09:07:42 -04:00
Nathan Braswell
8b3cab7a2f
Fix multiple cond/slice bugs revealed by LotusRonin's new find testcase
2022-04-24 20:39:51 -04:00
Nathan Braswell
8a876a7b29
Merge pull request #6 from Limvot/md5_hash_func
...
Add 32 bit int to hex string and leftrotate impls. Also some string functions
2022-04-23 13:42:22 -04:00
Nathan Braswell
6c51639c6e
Thread through inline_symbols and inline_level to prep for inlining impl
2022-04-23 01:41:52 -04:00
Nathan Braswell
18250e716f
Ah, the remaining calls were to =. Added 'inlining' the = and comp_helper loop into repeated calls to comp_helper_helper, eliminating the param array overhead. Now fib only allocates 10 times (instead of 4 million), and runs in .107s, finally beating Python handilly and becoming about 2x as slow as Chez. Feels like a decent spot for now, and that was most all of the low hanging fruit. The only thing left now is inlining of user functions to get fib_let performing as well - it looks glacial now at .4s because of the 2 remaining closure calls that the let expands to
2022-04-21 01:09:10 -04:00
Nathan Braswell
0cb52eb0b4
Add inlining of add and subtract, and now might be beating Python, though not by a statistically significant amount with the number of tests. Fib is still allocating 4 million times or so, which is weird, since +&- should have been the last calls to do so. Time to track that down
2022-04-20 23:47:36 -04:00
Nathan Braswell
ec9f8d9d10
Implement unwrapped static calls! Modest speedup of 0.50 -> 0.43, I belive because calls to + and - still create the arrays. Still less than expected, though
2022-04-20 02:27:22 -04:00
Nathan Braswell
c2dbac67f5
Add, and move setup to, wrapper func for each user func. Next need to actually call the non-wrapper version if applicable...
2022-04-19 02:00:56 -04:00
Nathan Braswell
5cdaafebe2
Change lapply to optionally take in an explicit env, make it optional for vapply so they match, then tweak Y such that it threads the dynamic env through, then implement eta-reduction in the compiler backend. This provides about the same speedup again from the Y elimination, as it's kinda the other half for fully getting rid of Y such that there's just static recursive calls. fib.kp went from 1.7 -> 1.1 -> 0.5, and fib_let similarly. fib.kp is now faster than fib_manual, but just by a bit.
2022-04-17 01:52:01 -04:00
Nathan Braswell
3009b62f5e
Mostly eliminating Y combinator at compilation time by putting function values in memo early if we have env_val and we put in the anti-recursion hash from the partially evaled call that returned this comb, and then compiling calls also looks for its recursion-stopped hashes in memo. To finish the transformation, I need to perform an Eta-reduction as well, but we've already got over half of the speedup from eliminting the Y part and just leaving (lambda (& y) (lapply <now_const_func!> y)).
2022-04-14 02:49:00 -04:00
Nathan Braswell
8b21a6c55e
Use hyperfine to benchmark, add builtin_fib as a comparison for how fast we could try to be
2022-04-13 00:25:53 -04:00
Nathan Braswell
c6071dbbe1
bunch more testcases
2022-04-12 00:14:09 -04:00
Nathan Braswell
55afa8977e
Add rust example
2022-04-11 16:07:11 -04:00
Nathan Braswell
645b9f7172
Perhaps over-compilicated attempt to only reify envs when actually necessary. Also got a speedup from simplifying params creation when neither varadic nor uses de, which is really the main speedup here. Hopefully this is still a step forwards that will become more apparent with the removal of reifing params too, and inlining. Might be being foiled by the recursive call going through Y or something. Did see a reduction in allocations with the no-reifying thing, but only from 35mil to 34mil. Seems like it should be more with the number of leaf calls in fib, not sure whats up. Maybe there's more overhead going through Y than I thought and its all of that?
2022-04-11 02:17:17 -04:00
Nathan Braswell
d92f774c33
Add help message based on Marcus's suggestion
2022-04-10 10:45:52 -04:00
Nathan Braswell
1149363e62
Add debug_levels and turn off stack_traces by default, but save enough info about the last interaction with the top-level loop to enable re-running to problem spot with debugging on if it happens, and it works! This is the first step towards the opt/non-opt-wrap work while maintaining debugability
2022-04-09 00:45:58 -04:00
Nathan Braswell
7116012be1
Better debug parameter message
2022-04-06 00:24:34 -04:00
Nathan Braswell
dcc81ac2eb
make prints of top level strings not include the quotes
2022-04-06 00:13:46 -04:00
Nathan Braswell
db7c258d39
Make printing stack/env nicer
2022-04-05 23:59:18 -04:00
Nathan Braswell
29f02810f8
More debug work, including adding the code tracking throught marked_array for the stack traces, calling into debug when eval has a symbol not defined error (just the first error spot to do this, we can add them all gradually), allowing abort for debug, and adding (exit val) for debug that resumes execution
2022-04-05 00:30:03 -04:00
Nathan Braswell
99e24ac6a0
Add rough stack trace
2022-04-04 01:35:06 -04:00
Nathan Braswell
00299a8d3a
Fixed read, started in on a debug function with a repl and ability to exit. Haven't actually added any other debug functionality, but thought about how to do stack traces (linked list of env functional val pairs).
2022-04-02 01:01:34 -04:00
Nathan Braswell
d5b11ca037
compile static calls to static wasm calls
2022-04-01 01:06:40 -04:00
Nathan Braswell
b87afc6a12
Round allocated blocks up to the nearest 8 words, and split blocks that are >= 2x needed number of words. Now only allocates 1 wasm page for both compiled and interpreted versions at fib 30, a 269-538x improvement!
2022-03-30 21:27:01 -04:00
Nathan Braswell
b85873b240
Fixed a terrible bug where turns out I used the same name for a block and a parameter in the comparison meta-function -
...
they share the same namespace in the wasm DSL, so when I used it like a parameter in a loop it resolved to the number of scopes between the statement and the block'th parameter
which had the same type and the calculation worked fine, but it overwrote the parameter I thought wasn't being used and called a function later with.
Also, that seemed like that last of the really bad leaks & corruption, so re-enabling the freelist and am able to run some less-trivial benchmarks, namely (fib 30)!
The compiled version is between 4.7x and 65x slower than Python, depending on if you're using wasmer, wasmtime, wasm3. Would like to try WAVM as well.
A solid place to start, I think, and hopefully we'll be faster than Python once I implement a variety of dont-be-dumb optimizations (real-er malloc, static calls of statically known functions, etc)
2022-03-29 23:49:51 -04:00
Nathan Braswell
cb41fe3fc8
Added a singlely-linked list with the value-created 2 word header to mallocd blocks that tracks everything ever malloced, and an assertion on free that the refcount is 0. Found what I think was a (the?) key source of corruption - drop moving the ptr forwards to drop subs, but then freeing that moved ptr. Now fixed, things look much less weird, but there are remaining memory leaks to track down
2022-03-28 23:57:38 -04:00
Nathan Braswell
f5ba367096
Debugging refcounting, fixed 3 mem leaks so far
2022-03-24 01:58:49 -04:00
Nathan Braswell
5c1473d32c
Continue brain-dumping psudocode and notes. I think I've got most everything critical now
2022-03-21 23:52:07 -04:00
Nathan Braswell
b3122f62d1
Started brain-dumping psudocode and descriptions of interesting points/contributions, the reason all macro-like combiners should be partially-evaled away, the invarients we must maintain, etc
2022-03-21 01:03:54 -04:00
Nathan Braswell
0c554078bd
Found the offending code for the infinate recursion, though not exactly why it happens. Minimal reproducer seemingly found
2022-03-20 20:50:39 -04:00
Nathan Braswell
eb3a732f99
Add fib_let test and script to run all of them. Indeed, the version with the let is worse when interpreted and the same/better when partially-evaled and compiled
2022-03-20 16:01:38 -04:00
Nathan Braswell
6fa2c44619
Add no_compile option to test more staight dynamic eval with a fib and fact test. Compiled is faster, though only 2x on fib - I imagine the hot inner loop isn't actually doing a lot that can be partial evaled, it's the outside. Will need tests that excercise more
2022-03-19 01:48:58 -04:00
Nathan Braswell
f0d68c3efe
Finally implemented runtime vau with varadic, which involved a half-rewrite
2022-03-17 23:20:22 -04:00
Nathan Braswell
f10be4511f
Add support for de to runtime vaus as well as parameter length checking. Do need to add support for varidac functions...
2022-03-17 00:35:21 -04:00
Nathan Braswell
1a2ecd65b0
Implemented runtime vau, but still need to add support for functions taking in the dynamic env (gotta shift those env arrays around)
2022-03-16 02:10:29 -04:00
Nathan Braswell
67ba716003
Add runtime version of cond
2022-03-15 02:13:42 -04:00
Nathan Braswell
31ee20be7b
Implemented wasm eval and fixed slice
2022-03-13 22:56:04 -04:00
Nathan Braswell
1b220023bc
Fix cond to not die on guarded errors, implement a new if in macro-style, port some more over to_compile.kp. Stopped just before 'vau, which seems to loop forever or somesuch
2022-03-13 15:11:30 -04:00
Nathan Braswell
947d854ebb
Implement array functions (len idx slice concat) for strings in wasm versions. All work - note I think slice is broken (or at least exposes brokenness) for arrays (not the newly adding strings)!
2022-03-13 01:44:38 -05:00
Nathan Braswell
d1b6e520f9
Added support for strings to array functions for evaluator (compiled is next)
2022-03-12 20:19:00 -05:00
Nathan Braswell
d87f292c1c
Additional optimization using intset for env_stack, some small bugfixes regarding not making a marked_array out of components that errored, moved over a lot of code to to_compile.kp.
2022-03-10 01:06:44 -05:00
Nathan Braswell
a08415e1e6
Cleanup & some demo code for presentation
2022-03-08 15:55:59 -05:00
Nathan Braswell
7fed3a58f5
Added more to to_compile.kp and runtime started growing again - main bottleneck was the silly using lists as sets thing, changed the small-int uses of these to a new custom bitset and brought the time from 47s back down to 6s. There is a remaining hotspot where partial_eval_helper matches needed_for_progress vs the bitset, but that'll have to wait for tomorrow. Thinking of maintaining a env_stack bitset and adding a bitset_union_nonempty function. Note the new bitset does use some cons/car/cdr operations that'll be a bit different in Kraken, which I'll need to look at. Maybe when porting I can just use indexing if there's not a great way to unify them.
2022-03-08 02:54:26 -05:00
Nathan Braswell
90fe8e1bfa
Bunch of optimization that took us from 3:50 to 0:04 for the current to_compile.kp. Mainly pulling len out of hot loops and using a naive binary tree instead of alists for maps
2022-03-07 02:10:42 -05:00
Nathan Braswell
c8c9bba429
Have nodes carry around information about the additional non-real envs that aren't real because of a non-real env in their chain. These envs don't show up in needed partial idxs, since it's the up the chain env that actually needs progressing, but allow us to do check-for-env-id normally in essentially O(1). This made the function much more efficient by number of invocations and cut some of the other hottest functions by nearly an order of magnitude, but only took 15-20 seconds off of a 4 minute compile. This is unfortunate (Chez profile only shows invocation numbers, not time numbers, so this is hard to tell) but at least this part is better now.
2022-03-06 03:22:35 -05:00
Nathan Braswell
bf1f81cdf3
Implement and and or. Looks like nil doesn't currently count as false, based false? and it seems to be avoided even with the compiled 'vcond, though it looks like it shouldn't (oh this is probs it being partially evaled ahead of time, isn't it?) Anyway, we might want to finish this and remove it from vcond too
2022-03-03 09:28:01 -05:00
Nathan Braswell
8cdf41826b
Starting to port over & self-host!
2022-03-03 00:33:25 -05:00
Nathan Braswell
4a273c9ba2
Bigfix error infinite recursion, error printing, wrap_level not being in hash_comb, extend to_compile.kp a bit
2022-03-02 01:44:20 -05:00
Nathan Braswell
dd0463d059
Comment out generated debugging and other log based code for large speedup - tried several other optimizations but they counterintitively made things worse
2022-02-28 23:47:02 -05:00
Nathan Braswell
3f26a3ad7d
Finish porting mif and fixing up other inconsistancies. Fix bug for emitting signed numbers as hex in compile. Runs correctly in both Chez and Chicken interpreter now, which Chez being about 3x faster
2022-02-28 00:27:19 -05:00
Nathan Braswell
ea15f48d6f
Implement dlambda and correct dlet. More attempt at Gambit
2022-02-23 16:43:03 -05:00
Nathan Braswell
54097ac074
Port the let+ macro from http://www.phyast.pitt.edu/~micheles/scheme/scheme15.html over mostly, and it works in both Chez and Chicken! Will massage some more to get it to be the same as our previous dlet, but it is working!
2022-02-23 00:56:46 -05:00
Nathan Braswell
f8bab2ada5
I caught the Chicken compiler red handed, it's compiled version has zip change behavior part way through, caught in the act with some prints. Where it does so changes based on optimization level, which is a bad sign. Starting a (hopfully quick) port to more standard scheme - looking to support Chez and Gambit in addition to Chicken, with at least some commented out code if not some sort of conditional compilation. We're off to a roaring start with define-syntax broken in Gambit 4.9.3, from 2019, but there was a new version released last month that I think should fix it.
2022-02-22 02:19:17 -05:00
Nathan Braswell
58f3d7858e
Rework the destructuring lambda in what I'm now calling the true-macro-style, so that helper functions don't close over the dynamic env and cause it to not partially evaluate away
2022-02-20 23:42:09 -05:00
Nathan Braswell
2874be3332
Fix the bug with de getting seperate dynamic envs, now unified but no opts for now (doing it seperetly was broken because of tyring to access it from inner closures. Also add a lot more runtime logging
2022-02-20 22:12:21 -05:00