Commit graph

4254 commits

Author SHA1 Message Date
Leonardo de Moura
8e9b0d2799 fix(library/compiler): inferred types for stage2 declarations 2019-03-06 17:24:43 -08:00
Sebastian Ullrich
3b06c52d4f test(tests/playground/Makefile): re-add original ocamlopt parameters
This reverts commit 8e212ef9d9.
2019-03-05 15:44:42 +01:00
Sebastian Ullrich
069c07fa39 test(tests/playground/Makefile): update 2019-03-05 15:44:39 +01:00
Sebastian Ullrich
90a058a655 test(tests/playground/Makefile): bench fallback, all Lean tests 2019-03-05 15:44:03 +01:00
Sebastian Ullrich
467799c6c3 test(tests/playground/run.sh): fix 2019-03-05 15:37:11 +01:00
Leonardo de Moura
e5950cf710 test(tests/playground/gen): simple lean file generator
@kha
I am using this little program to generate big lean files to test the
new front end. For the output produced for `gen 5000`, the new frontend
is almost 10x slower than the old one.
I used `valgrind --tool=callgrind` to collect profiling data.
The number of closures is too big. For example, `free_closure_obj` was
invoked 38.5 million times. The total number of deallocated objects is around
49.5 million.
2019-03-04 16:19:50 -08:00
Leonardo de Moura
9cc41c4f3d chore(frontends/lean/inductive_cmds): disable broken check
@kha I have disabled this check. It was implemented 2 years ago by
Daniel, and I don't want to fix it. It seems you have already fixed a
bug there. AFAICT, this check is just for improving error messages.
I believe we may not even need it since the kernel now supports nested
inductive types. AFAIR, Daniel implemented this check here because the
inductive compiler was introducing a lot of auxiliary declarations
that were making the kernel error messages unreadable.
2019-03-04 11:05:21 -08:00
Sebastian Ullrich
5e7970dca3 test(tests/playground/deriv): Haskell version 2019-02-28 14:57:57 +01:00
Leonardo de Moura
b25c0db35d tests(tests/playground/deriv): deriv in OCaml 2019-02-27 11:15:52 -08:00
Leonardo de Moura
f4302a5f48 test(tests/playground): new versions of unionfind1
@kha I'm just trying to understand the performance numbers.
2019-02-26 16:47:53 -08:00
Leonardo de Moura
d128af10f9 test(tests/playground): add union find examples
@kha I tried to make the examples self contained.

- unionfind1.lean uses the modified StateT and ExceptT
- unionfind2.lean uses the standard StateT and ExceptT
2019-02-26 13:44:16 -08:00
Sebastian Ullrich
f366af76ac test(tests/playground/rbmap): consistent naming 2019-02-26 20:27:23 +01:00
Sebastian Ullrich
850001b996 test(tests/playground): rbmap.hs, Makefile 2019-02-26 20:26:55 +01:00
Sebastian Ullrich
c4bc783ef4 test(tests/playground/run.sh): split out compile.sh 2019-02-26 20:25:30 +01:00
Leonardo de Moura
6f73f19d19 chore(tests/playground/rbmap_standalone): make sure lean version mirrors the OCaml one 2019-02-26 10:37:12 -08:00
Leonardo de Moura
b883388d66 chore(tests/playground/rbmap_standalone): add missing [specialize] and remove alias 2019-02-26 10:06:18 -08:00
Leonardo de Moura
397be6d1c0 test(tests/playground/rbmap_standalone): add standalone rbmap benchmark 2019-02-26 09:56:59 -08:00
Sebastian Ullrich
d258f325f1 test(tests/playground/binarytrees.lean): further opt 2019-02-26 18:08:09 +01:00
Sebastian Ullrich
24ad2e2b89 test(tests/playground/binarytrees.lean): optimize 2019-02-26 17:47:14 +01:00
Sebastian Ullrich
8e212ef9d9 test(tests/playground/Makefile): these ocamlopt parameters do nothing 2019-02-26 17:26:37 +01:00
Sebastian Ullrich
70a5c6d585 test(tests/playground/binarytrees.lean): more coarse parallelization 2019-02-26 17:21:45 +01:00
Sebastian Ullrich
9724491dc2 test(tests/playground/binarytrees.lean): parallelize 2019-02-26 16:16:34 +01:00
Sebastian Ullrich
cf0bf911c8 test(tests/playground): binarytrees benchmarks game benchmark in Lean, OCaml & Haskell 2019-02-25 23:46:10 +01:00
Sebastian Ullrich
c4740b7295 test(tests/playground/rbmap.ml): take the same input as Lean version 2019-02-25 14:51:16 +01:00
Leonardo de Moura
ccea4c2043 chore(tests/playground/rbmap): use +1 instead of +k to avoid big number arithmetic when we increase number of elements inserted 2019-02-24 08:49:38 -08:00
Leonardo de Moura
483125f828 test(tests/playground/rbmap): rbmap in OCaml 2019-02-22 17:43:27 -08:00
Leonardo de Moura
8decfcae74 test(tests/playground): manually optimized rbmap3 2019-02-20 11:00:54 -08:00
Leonardo de Moura
1fc058503d fix(tests/playground/rbmap3): bug 2019-02-19 22:40:22 -08:00
Leonardo de Moura
3e8c8bf3a1 chore(tests/playground/rbmap2): remove debugging options 2019-02-19 22:34:38 -08:00
Leonardo de Moura
5db219aae5 test(tests/playground): rbmap example
@kha The Lean rbmap is 3x slower than the C++ rb_map.
I tried two different implementations: rbmap2 (Appel's Coq
implementation), and rbmap3 (tries to simulate the C++ version).
I believe rbmap3 is broken since it is too slow.
I have also identified missing reset/reuse opportunities.
The actual implementation misses a case the simple code at reuse.txt gets :(
rbmap3 also exposes the "TODO(Leo): improve this" at library/compiler/reduce_arity.cpp
2019-02-19 19:01:51 -08:00
Sebastian Ullrich
76753a0696 test(tests/playground/expr_const_folding): add Swift translation 2019-02-19 11:24:10 +01:00
Sebastian Ullrich
ddab7bcea8 test(tests/playground/expr_const_folding): Haskell version 2019-02-18 14:59:33 +01:00
Sebastian Ullrich
59d19aee2b test(tests/playground/expr_const_folding): fix Lean version 2019-02-18 14:29:07 +01:00
Leonardo de Moura
aff5f96a3d test(tests/playground): simple task benchmarks 2019-02-17 11:47:02 -08:00
Leonardo de Moura
dfce086c9e test(tests/compiler/array_test): basic array test 2019-02-16 16:08:49 -08:00
Leonardo de Moura
821bdcdac0 chore(tests/playground): add helper files 2019-02-15 18:13:37 -08:00
Leonardo de Moura
542bd432f8 test(tests/compiler): uint constant folding tests 2019-02-15 14:53:29 -08:00
Sebastian Ullrich
03456ab752 chore(tests/compiler/t2): fix test 2019-02-15 12:13:45 -08:00
Sebastian Ullrich
b8900fad80 chore(tests/compiler/test.sh): rename to conventional test_single.sh so that (lean4-diff-test-file) works 2019-02-15 12:13:45 -08:00
Leonardo de Moura
eef60279e4 tests(tests/playground/expr_const_folding): another example for the paper
@kha I implemented a more complex example for the paper. The difference
in performance is awesome. On my Linux desktop:

Lean time:  3.34  secs
OCaml time: 11.72 secs

I believe that the difference in performance is due to destructive
updates happening in transformation functions such as `reassoc` and
`const_folding`. I will add a flag to Lean to disable `reuse/reset`
automatic insertion.

BTW, this test requires `ulimit -s unlimited` to avoid stack overflows.
2019-02-15 12:07:52 -08:00
Leonardo de Moura
f879cdb12f test(tests/playground): add new example in Lean and OCaml
@kha I wrote a simple test in Lean and OCaml. Right now, the numbers on
my machine are

arith_eval.ml         8.13 secs
arith_eval_nat.lean   10.71 secs

OCaml is computing with machine boxed integers, and we are computing
with `nat`. Our version is more expensive since we have to check
whether the number is small or big, and whether the result needs to be a
mpz value or not.

Almost half of our runtime is spent deallocating the big object returned
by `mk_expr`. The deferred free feature does not help here because
we don't deallocate the object in the end but as we execute `eeval`.
So, we perform many small invocations to `del`. None of them take
long, but the overall cost is super high. I can use a different strategy
where `del(o)` just updates the `g_to_free` list, and we deallocate
at most `LEAN_DEFERRED_FREE_QUOTA` at each allocation. The current
deferred free approach would also work if we could use the borrowed
annotations in `eeval`. In this case, we would not delete the input
expression as we evaluate it.

As an experiment, I manually added a `lean::inc` before invoking
`eeval`. The idea was prevent memory deallocation. With this
modification, the program runs in 5.87 secs.

BTW, I also wrote a version using uint32 (arith_eval_uint32.lean),
but the current compiler generates poor code for it.
I know how to fix the performance problem.
2019-02-14 15:50:07 -08:00
Leonardo de Moura
6083bde3bc chore(tests/playground/deriv): add example for testing in the playground 2019-02-14 10:49:46 -08:00
Leonardo de Moura
b6d1506434 fix(tests/compiler/t2): pause at the end
@kha I figured out why we had a long pause in the end of this benchmark
when using `11` instead of `9`. The function `deriv` was computing
`d := d "x" f` (the expensive computation), printing the size of `f` and
returning `d`. So, in the last step we were quickly printing the size
of the input 40230090 (when using `nest deriv 11 f`), and then computing
`d := d "x" f` which returns an object of size 374429936 which is never
used for anything.
That is, the pause had nothing to do with memory deallocation. I found
this issue after I implemented the deferred free feature which did not
fix the pause :)
2019-02-14 10:44:59 -08:00
Leonardo de Moura
1716f1f6c9 test(tests/playground/perf): performance test
On my macbook,
- with default kind STHeap: 3.15 secs
- with default kind MTHeap: 3.75 secs

@cc kha
2019-02-14 08:43:04 -08:00
Leonardo de Moura
6f852cf7af feat(tests/playground): add run.sh script for running tests
@kha I have added `timeit` for running experiments for the paper.
We have to be careful because `timeit` may produce incorrect results
due to compiler optimizations (e.g., ground term extraction).
Here are examples that do not produce the result we expect:

```
def main : io uint32 :=
timeit "tst" (io.println' ("result " ++ to_string (tst 1000000))) *>
pure 0
```

```
def main (xs : list string) : io uint32 :=
timeit "tst" (io.println' ("result " ++ to_string (tst xs.head.to_nat))) *>
pure 0
```
2019-02-13 17:17:14 -08:00
Leonardo de Moura
19e111c2ff feat(library/compiler): allow main function to also have type io uint32 2019-02-13 16:29:10 -08:00
Leonardo de Moura
06bb9b7ea8 test(tests/compiler): add simple test for expr 2019-02-13 16:22:01 -08:00
Sebastian Ullrich
534b507aff feat(library/init/lean/frontend): rework error reporting 2019-02-12 13:34:32 +01:00
Leonardo de Moura
7e8f9e6f66 feat(library/compiler): add [extern] attribute 2019-02-09 18:53:44 -08:00
Sebastian Ullrich
67f8f7a2da chore(tests/compiler/append): add expected output 2019-02-09 20:02:26 +01:00