New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange behavior of to_lua with LPeg 0.12
#150
Comments
|
As I pointed out on lua-l, this is lpeg 0.12 specific. Both LuLPeg (whose API derives from v0.12) and LPegLJ (which is a straight port of v0.12, now augmented for left recursion) work fine. |
|
OK, but this renders LPeg 0.12 unusable for our application. In fact we have reverted today to LPeg 0.10.2. |
|
LPegLJ is usually faster than this. For parsing MoonScript, it is slower than LuLPeg with Lua 5.1... It is normally on par with LuLpeg + LuaJIT. I've adapted your script to parse the MoonScript test suite: package.loaded.lpeg=require((...))
local to_lua = require("moonscript.base").to_lua
local l = {}
for file in io.popen"ls /Users/pygy/src/moonscript/spec/inputs":read"*a":gmatch"%S+%.moon" do
l[file]=io.open("/Users/pygy/src/moonscript/spec/inputs/"..file):read"*a"
end
local t = os.clock()
for _, v in pairs(l) do to_lua(v) end
print(os.clock() - t)
LuaJIT 2.0 and 2.1 perform identically. If I'm not mistaken, LPeg 0.10 is faster than LPeg 0.12, but I don't have it at hand. |
|
Many thanks for these interesting data! |
|
A minimal test case would definitely help, debugging this based on the MoonScript parser may not be easy. Do you already know what is going on? BTW, out of curiosity, what kind of performance do you get with LPeg v0.10? Could you post your the local results of my benchmark with both v0.10 and 0.12? |
|
No, I don't know what's going on. BTW, I see you're not on Windows, could you confirm the issue with LPeg 0.12 on your system? With my original test, do you get increasing times and error like I do? My local results:
|
|
Yes, I can reproduce it in OS X. Same behavior exactly: Thanks for the numbers :-) |
|
TTree::key overflows. |
|
It is set in settoktable(), based on the length of various lua tables ( I'm surprised it grows at parse time. |
|
Sorry for not responding. This has been a known issue for quite some time. It looks like the culprit is related to how the parser automatically generate non-terminals: http://lua-users.org/lists/lua-l/2015-02/msg00035.html |
|
possible that this is not moonscript related problem. here http://lua-users.org/lists/lua-l/2015-02/msg00352.html I provided testcase without moonscript. |
|
Thanks for taking the time to look into it |
|
removing the cache for lpeg.V seems to fix all instances where I could reproduce problem. |
|
eats ktable entries slowly, but stil crashes after ~7200 calls: local to_lua = require("moonscript.parse").string for me its only lpeg problem. |
|
I agree it's an lpeg problem, but I should do the best I can to mitigate it until it's fixed. |
|
with 0.12.2 0.2.6 and 0.3.0 versions works fine. |
|
great news :) |
[Windows XP SP3, MinGW, Lua 5.1, MoonScript 0.2.6]
The following test behaves OK with LPeg 0.10.2 but throws an error with LPeg 0.12
Output with LPeg 0.10.2:
Output with LPeg 0.12:
The text was updated successfully, but these errors were encountered: