google / grumpy

Grumpy is a Python to Go source code transcompiler and runtime.
Apache License 2.0
10.54k stars 648 forks source link

77 seconds to run hello world #388

Open ShakataGaNai opened 6 years ago

ShakataGaNai commented 6 years ago

image

77 seconds to compile the hello world, this was the second time I ran it - so if there is cacheing/downloading to do - it should have already done it. I think the first time was even slower than this, but I didn't time that.

vbarbaresi commented 6 years ago

I can reproduce on OSX Sierra as well. For some reason, on the second make run, a lot of targets remain:

$ echo "print 'hello, world'" | make run -n
mkdir -p build/src/__python__/__go__/grumpy
build/bin/pkgc grumpy > build/src/__python__/__go__/grumpy/module.go
mkdir -p build/pkg/darwin_amd64/__python__/__go__
go install __python__/__go__/grumpy
mkdir -p build/pkg/darwin_amd64/__python__
go tool compile -o build/pkg/darwin_amd64/__python__/__builtin__.a -p __python__/__builtin__ -complete -I build/pkg/darwin_amd64 -pack build/src/__python__/__builtin__/module.go
mkdir -p build/pkg/darwin_amd64/__python__
go tool compile -o build/pkg/darwin_amd64/__python__/sys.a -p __python__/sys -complete -I build/pkg/darwin_amd64 -pack build/src/__python__/sys/module.go
mkdir -p build/pkg/darwin_amd64/__python__
go tool compile -o build/pkg/darwin_amd64/__python__/cStringIO.a -p __python__/cStringIO -complete -I build/pkg/darwin_amd64 -pack build/src/__python__/cStringIO/module.go
mkdir -p build/pkg/darwin_amd64/__python__
go tool compile -o build/pkg/darwin_amd64/__python__/exceptions.a -p __python__/exceptions -complete -I build/pkg/darwin_amd64 -pack build/src/__python__/exceptions/module.go
mkdir -p build/pkg/darwin_amd64/__python__
go tool compile -o build/pkg/darwin_amd64/__python__/thread.a -p __python__/thread -complete -I build/pkg/darwin_amd64 -pack build/src/__python__/thread/module.go
mkdir -p build/pkg/darwin_amd64/__python__
go tool compile -o build/pkg/darwin_amd64/__python__/_collections.a -p __python__/_collections -complete -I build/pkg/darwin_amd64 -pack build/src/__python__/_collections/module.go
mkdir -p build/pkg/darwin_amd64/__python__
go tool compile -o build/pkg/darwin_amd64/__python__/itertools.a -p __python__/itertools -complete -I build/pkg/darwin_amd64 -pack build/src/__python__/itertools/module.go
mkdir -p build/pkg/darwin_amd64/__python__
go tool compile -o build/pkg/darwin_amd64/__python__/os.a -p __python__/os -complete -I build/pkg/darwin_amd64 -pack build/src/__python__/os/module.go
mkdir -p build/pkg/darwin_amd64/__python__
go tool compile -o build/pkg/darwin_amd64/__python__/linecache.a -p __python__/linecache -complete -I build/pkg/darwin_amd64 -pack build/src/__python__/linecache/module.go
mkdir -p build/pkg/darwin_amd64/__python__
[...]

Although the .a files already exist, they will be rebuilt, not sure why

From the third run it stops compiling and works fast

alanjds commented 6 years ago

Just to inform: I am working on this issue.

$ echo "print 'hello, world'" | time grumpy run
hello, world
        0.90 real         0.85 user         0.22 sys
$ uname -a
Darwin mymachine.local 16.0.0 Darwin Kernel Version 16.0.0: Mon Aug 29 17:56:20 PDT 2016; root:xnu-3789.1.32~3/RELEASE_X86_64 x86_64

Machine: MacBookPro12,1

Will followup later. Yet a lot of stuff to optimize on the importing routines

alanjds commented 6 years ago

Just published a "grumpy-runtime" package on PyPI. It installs the grumpy CLI tool and compiles the runtime on your machine. Took 3 min. on my notebook.

Then you can run:

$ echo "print 'hello'" | grumpy run

And it takes ~2 seconds on my machine.

Published yesterday and is very beta right now, but opens world to cache compiled stuff on __pycache__ folders.

Please provide feedback if you can.