lean icon indicating copy to clipboard operation
lean copied to clipboard

Simple programs run for many seconds

Open yurivict opened this issue 3 years ago • 8 comments

Prerequisites

  • [x] Put an X between the brackets on this line if you have done all of the following:
    • Checked that your issue isn't already filed.
    • Reduced the issue to a self-contained, reproducible test case.

Description

Simple type programs run for many seconds. For instance, this example runs for many seconds both on the website and when run from the terminal.

Versions

Version: 3.48.0

yurivict avatar Sep 01 '22 04:09 yurivict

I can't reproduce this issue. The live version on the website takes a couple of seconds to load (no matter the file), but after that your example is instantaneous.

gebner avatar Sep 02 '22 16:09 gebner

Is C++ compiled version instantaneous for you on simple scripts? Then I need to profile it.

yurivict avatar Sep 02 '22 17:09 yurivict

It takes around 350ms.

gebner avatar Sep 02 '22 17:09 gebner

Simple program takes ~22 sec on FreeBSD:

$ time lean simple.lean 
m : ℕ

real	0m22.868s
user	0m51.723s
sys	0m0.505s

yurivict avatar Sep 02 '22 20:09 yurivict

I got this profile: image

Some functions are called 1.5+ billion times, and many functions are called over 500 million times. I don't think you even have so many objects of any kind. Some of the algorithms are obviously inefficient.

C++ library is different on FreeBSD, this might have causes the compiler to interpret some code differently.

yurivict avatar Sep 03 '22 15:09 yurivict

I am pretty sure that there is a C++ problem in the code. Maybe some shared_ptr is copied often when this isn't needed - passing by address usually suffices.

yurivict avatar Sep 03 '22 15:09 yurivict

I think all you need to do is:

cd lean/library
lean --make

gebner avatar Sep 05 '22 14:09 gebner

This solved the problem.

But why isn't this done in the course of normal build? There is the code for this in CMakeLists.txt, but it isn't run for some reason.

yurivict avatar Sep 05 '22 17:09 yurivict