Hi, I have encountered a problem with Parrot. I am mainly interested in running lua code in parrot so I have been testing the PCT tools for Lua. When running this test file included with the Lua distribution (\Lua\5.1\examples\fib.lua), I get the following results:
# Running in Lua VM >lua fib.lua n value time evals plain 24 46368 0.125 150049 cached 24 46368 0 25 # Running through lua.pbc >parrot c:\parrot-0.8.2\languages\lua\lua.pbc fib.lua n value time evals plain 24 46368 219.171 150049 cached 24 46368 0.125 25 # Compiled to PIR >parrot fib.pir n value time evals plain 24 46368 211.5 150049 cached 24 46368 0.092999999999989 25 # Compiled to PBC >parrot fib.pbc n value time evals plain 24 46368 201.5 150049 cached 24 46368 0.21799999999999 25 I found it very strange that the same simple program run by his native interpreter is more than 2000 times faster than running on Parrot. I suspected that the compiler was not doing the job properly so I decided to compare the source code of a native pir implementation of the Fibonacci Benchmark located at \parrot-0.8.2\share\doc\parrot\examples\benchmarks\fib.pir with my own implementation of the same algorithm in lua compiled to pir. Here are the logs of my tests , attached are the relevant files (fib-benchmark.pir is the original fib.pir located at \parrot-0.8.2\share\doc\parrot\examples\benchmarks\fib.pir, I renamed it for convenience. fibsek.lua is my lua implementation of the Fibonacci Benchmark and fibsek.pir is the result of >parrot luap.pir --target=pir project\fibsek.lua > fibsek.pir) ################################################################## # Native PIR implementation runs ok >parrot fib-benchmark.pir fib(28) = 317811 13.625s # My script runs ok on Lua >lua fibsek.lua fib( 28 ) = 317811 crunching time = 0.31 seconds # Running the lua script through lua.pbc -- The computer hangs during 5 minutes with cpu 100% and ram consumption going up to 300 MB. >parrot c:\parrot-0.8.2\languages\lua\lua.pbc "fibsek.lua" Parrot VM: PANIC: Out of mem! C file src\gc\memory.c, line 137 Parrot file (not available), line (not available) We highly suggest you notify the Parrot team if you have not been working on Parrot. Use parrotbug (located in parrot's root directory) or send an e-mail to parrot-port...@perl.org. Include the entire text of this error message and the text of the script that generated the error. If you've made any modifications to Parrot, please describe them as well. Version : 0.8.2 Configured : Wed Dec 17 08:43:13 2008 GMT Architecture: i386-MSWin32 JIT Capable : Yes Interp Flags: (no interpreter) Exceptions : (missing from core) Dumping Core... Sorry, coredump is not yet implemented for this platform. # After that I compiled the lua script to PIR to compare both PIR code. The fip-benchmark.pir has 38 lines of code whereas my compiled pir file has 128 lines of code >parrot luap.pir --target=pir project\fibsek.lua > fibsek.pir # Running the generated PIR -- The computer hangs during 5 minutes with cpu 100% and ram consumption going up to 300 MB. >parrot fibsek.pir Parrot VM: PANIC: Out of mem! C file src\gc\memory.c, line 137 Parrot file (not available), line (not available) We highly suggest you notify the Parrot team if you have not been working on Parrot. Use parrotbug (located in parrot's root directory) or send an e-mail to parrot-port...@perl.org. Include the entire text of this error message and the text of the script that generated the error. If you've made any modifications to Parrot, please describe them as well. Version : 0.8.2 Configured : Wed Dec 17 08:43:13 2008 GMT Architecture: i386-MSWin32 JIT Capable : Yes Interp Flags: (no interpreter) Exceptions : (missing from core) Dumping Core... Sorry, coredump is not yet implemented for this platform. # After that I compiled both PIR files to PBC to be thorough >parrot -o fibsek.pbc fibsek.pir >parrot -o fib-benchmark.pbc fib-benchmark.pir >parrot fib-benchmark.pbc fib(28) = 317811 12.1719999313354s # Compiled to PBC -- Same story >parrot fibsek.pbc Parrot VM: PANIC: Out of mem! C file src\gc\memory.c, line 137 Parrot file (not available), line (not available) We highly suggest you notify the Parrot team if you have not been working on Parrot. Use parrotbug (located in parrot's root directory) or send an e-mail to parrot-port...@perl.org. Include the entire text of this error message and the text of the script that generated the error. If you've made any modifications to Parrot, please describe them as well. Version : 0.8.2 Configured : Wed Dec 17 08:43:13 2008 GMT Architecture: i386-MSWin32 JIT Capable : Yes Interp Flags: (no interpreter) Exceptions : (missing from core) Dumping Core... Sorry, coredump is not yet implemented for this platform. # The only way to complete the program successfully was to assign 24 to n >parrot c:\parrot-0.8.2\languages\lua\lua.pbc "fibsek.lua" fib( 24 ) = 46368 crunching time = 237.047 seconds I hope you have enough information. It seems to me it is an issue with the PGE but I am not sure. I will try to make more tests meanwhile. Cheers, Sekou.
fib-benchmark.pir
Description: Binary data
fibsek.lua
Description: Binary data
fibsek.pir
Description: Binary data
fib.lua
Description: Binary data