News for hackers. Stuff that matters.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by seabrookmx on Saturday November 26, 2022 @03:58PM (#33756659)
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by VWWHFSfQ on Saturday November 26, 2022 @04:07PM (#33756737)
I would recommend calling your project something else. ie, not LuaJIT.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by avaldez_ on Saturday November 26, 2022 @04:36PM (#33757023)
I'd call it Jaunatis (new moon in Lithuanian). A word play on Lua (moon in Portuguese).
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by ketralnis on Saturday November 26, 2022 @05:39PM (#33757585)
Agreed, this has the same "neovim: literally the future of vim" smell to it
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by HellsMaddy on Saturday November 26, 2022 @06:16PM (#33757977)
Neovim was a fork of Vim so it makes sense to keep the name similar, this project seems to be a completely new codebase.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by skorpeon87 on Saturday November 26, 2022 @06:23PM (#33758034)
NeoVim devs earned that 'Neo' by rapidly adding features that were in demand for years (and were subsequently implemented in Vim, in response to NeoVim's new pace of innovation.

Anyway, adding Neo was enough to differentiate the two names, so what's the problem? Let's not forget that Vim did the same thing to Vi when it was named "Vi IMproved."

Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by ketralnis on Saturday November 26, 2022 @07:09PM (#33758457)
It's not the name in the neovim case, it's the tagline "literally the future of vim" when vim was still being actively developed by a different group. It is IMO immoral for me to start a site called "Hacker News 2.0: The successor to Hacker News" and start telling people that I'm the next version of it and that's how that comes off to me.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by flumpcakes on Saturday November 26, 2022 @07:15PM (#33758504)
I understand your point, it does seem quite... rude? It reminds me of google calling their programming language "Go" while there was an existing language with that name already.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by CameronNemo on Sunday November 27, 2022 @01:27AM (#33760881)
They didn't call it Vim 9, though. It would be more like if you had a forum called NeoHacker News. Similar to "Hacker News"? Yes. More alliterative? Also yes. Misleading? Potentially not, with the right communication.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by mdaniel on Saturday November 26, 2022 @10:02PM (#33759766)
There was a similar comment in the other thread (https://news.ycombinator.com/item?id=33712759) with the outstanding (IMHO) suggestion of "Lua DeeJIT" as a nod to the Deegen framework it uses
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by mananaysiempre on Saturday November 26, 2022 @04:08PM (#33756745)
I’m a bit puzzled by the author’s statement that they’re building a method-at-a-time JIT here.

Sure, that’s an interesting thing you can do and get a Lua JIT, but I don’t see how that is going to be close to the original, tracing LuaJIT, where much of the simplicity (AFAICT) comes from how it creatively punts on several hard backend problems: optimizing in the presence of complex control flow (an linear sequence possibly followed by a loop, that’s all you get on the lowest level), tricky monomorphization decisions (the types you traced are the types you codegen for), eliminating allocations (exiled to trace exits as much as possible), etc.

Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by sillysaurusx on Saturday November 26, 2022 @04:24PM (#33756901)
Where did you learn that? I’ve been wanting to understand LuaJIT for years, but never got around to it.

Is there a “Heart of LuaJIT” style implementation somewhere? Something that’s like a thousand lines but conveys the core ideas.

Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by bch on Saturday November 26, 2022 @05:36PM (#33757557)
I think Mike Pall wrote up a whitepaper with the gory details years ago, but I can’t find it atm.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by sillysaurusx on Saturday November 26, 2022 @05:49PM (#33757674)
Damn. If you find anything related to it, I’ll happily Venmo you $20. (High roller, I know.)

The magic of making Lua so fast is seriously underrated. I’m fascinated why Lua in particular seems to be so amenable to speedups vs, say, Python bytecode or even Elisp bytecode.

Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by kzrdude on Saturday November 26, 2022 @05:58PM (#33757775)
Here are some places to start with, some of his "famous" mailing list posts: https://news.ycombinator.com/item?id=17329902 and 12 year old reddit bullet list of his too: https://old.reddit.com/r/programming/comments/badl2/luajit_2...
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by LAC-Tech on Saturday November 26, 2022 @06:20PM (#33758003)
Baseless speculation - was it because the VM was so small and well documented?

Never did program much in Lua but really enjoyed the parts where they describe the virtual machine and instruction set.

EDIT:

Link to the paper I mean https://www.lua.org/doc/jucs05.pdf

For a layman like myself this is very approachable. Again I cannot think of another VM language that has anything this small and well documented.

Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by panick21_ on Saturday November 26, 2022 @08:06PM (#33758909)
There was a great thread on lambda-the-ultimate where Mike and a some other famous JIT people talk about the benefits of different approaches. I highly recommend searching for those threads.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by celeritascelery on Saturday November 26, 2022 @11:35PM (#33760422)
Can you help me learn how to search for threads on LtU? I tried using the search box for lua but found nothing. Also failed to find anything in the archives.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by malkia on Sunday November 27, 2022 @12:16AM (#33760617)
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by panick21_ on Sunday November 27, 2022 @06:48PM (#33768209)
Sorry I read this like 10 years ago.

The other person he talks with is Andreas Gal and they talk about trace trees and method vs tracing jits.

Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by kzrdude on Monday November 28, 2022 @05:38AM (#33771930)
Isn't it the thread that's linked in previous messages in this comment section. Maybe the comment that I linked to in a different message.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by bch on Saturday November 26, 2022 @08:25PM (#33759057)
I’ll trawl my archives and maybe have a Christmas present for you.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by sillysaurusx on Saturday November 26, 2022 @08:34PM (#33759121)
You’re sweet. Thanks for the sentiment, whether or not you find anything. I hope you had a happy Thanksgiving, and that you have a fun and relaxing Christmas break. Cheers.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by scythe on Saturday November 26, 2022 @09:42PM (#33759641)
Lua naturally avoids hashing strings as much as possible. Short strings always have their hash precomputed and local variables are internalized. The default method for implementing variable scopes in dynamic languages just uses a lot of hash tables, but Lua cleverly avoids this:

https://github.com/lua/lua/blob/master/lobject.h#L549

https://github.com/lua/lua/blob/master/lstring.c#L185

Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by fbdab103 on Saturday November 26, 2022 @09:43PM (#33759644)
Not a language designer, but I have been told the big thing holding back Python is that it exposed too much of its internal guts to external APIs. With so much of the internals exposed, it becomes difficult to make some required backend changes.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by haberman on Saturday November 26, 2022 @10:15PM (#33759857)
Definitely that is true, I wrote a comment about that here: https://news.ycombinator.com/item?id=18041047

Another issue with Python is that the language semantics are much more subtle. This is an excellent talk that shows how even operations that appear simple in Python can be much more complex than they appear: https://youtu.be/qCGofLIzX6g

Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by CalebJohn on Saturday November 26, 2022 @11:44PM (#33760461)
Not the whitepaper, but here's some resources that I saved for myself to read that might be helpful.

https://www.freelists.org/post/luajit/How-does-LuaJITs-trace...

http://lua-users.org/lists/lua-l/2011-02/msg00742.html

Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by throwaway81523 on Sunday November 27, 2022 @03:17AM (#33761355)
I think I remember the whitepaper, but don't know where to find it these days.

Elisp bytecode now has a compiler using libgccjit, in Emacs 28.

LuaJIT simply did a lot of heavy lifting, implementing a full blown compiler with register allocation and all of that. Lua wasn't special that way. Rather, the Python devs didn't care that much about speed, and Python has the baked in notion that Python programs are a tree of nested dictionaries. Thus, there is only so much performance that could be wrung out of PyPy. But it still helps a lot.

Python 3 was of course a tragedy. If they were going to break stuff at all, they could have made some of that dynamicity optional (few programs use it). Then PyPy could have been the reference implementation and it would be crazy fast, eliminate the GIL, and so on. Just like Lisp implementations have done for 50+ years.

Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by Heliodex on Saturday November 26, 2022 @08:42PM (#33759185)
Very interesting to see how it performs against LuaJIT and standard Lua. Would love to see some metrics of it against Luau too.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by candrewlee14 on Sunday November 27, 2022 @03:14AM (#33761344)
It’s important to note too that the performance comparison is for the interpreters (not using JIT).
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by shaggie76 on Saturday November 26, 2022 @09:13PM (#33759399)
The real tragedy of JIT for games is you can't use it on consoles (AFAIK it's always been forbidden as a threat to security). I'm not sure what the rules are for mobile but I'd be surprised if Apple allowed it either.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by monocasa on Saturday November 26, 2022 @09:18PM (#33759434)
Yeah, iOS doesn't allow JITs except for javascriptcore.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by MBCook on Saturday November 26, 2022 @10:02PM (#33759770)
And it’s speculated for the same reason.

They’ve loosened up on interpreters, which is nice, but there is no way to make a JIT.

Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by MaxBarraclough on Sunday November 27, 2022 @05:19AM (#33761861)
I believe you're permitted to write a JIT that uses JavaScriptCore as its backend. This presumably includes WebAssembly.
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by stevefan1999 on Sunday November 27, 2022 @12:56AM (#33760771)
...add that to code generation part which means you will have to run a mini compiler + mini linker for each JIT program you run...how wasteful the CPU cycles and how power inefficient that would be
Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by pjmlp on Sunday November 27, 2022 @03:18AM (#33761356)
Unless it is an OS service like on Android, Inferno, Oberon, or the big iron computers from IBM and Unisys (where I agree power consumption isn't that relevant).

Which cache the generated code between runs, unless the original code changes, avoid each application shipping their own mini-JIT toolchain, and on Android's case AOT compile the application using the PGO data gathered by the JIT (also shared via PlayStore to other devices), when the device is idle and charging.

Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by HexDecOctBin on Sunday November 27, 2022 @12:10AM (#33760592)
> our implementation of the Lua table uses hidden class, instead of a naive hash table as in Lua/LuaJIT.

What is "hidden class"? Is this a data structure?

Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by albntomat0 on Sunday November 27, 2022 @12:36AM (#33760690)
In languages with dynamic properties on objects, it’s a data structure that keeps track of which properties are present, and how to access them.

Short example In JavaScript: Var a = {}; a.b = 15;

The hidden class object a maps the property b to where its stored, may include type information, etc.

Re:LuaJIT Remake: An ongoing attempt to re-engineer LuaJIT f... by inglor on Sunday November 27, 2022 @01:55AM (#33761013)
The optimization is usually called shapes outside of JS.

The idea is that shapes (we represent objects like C like structs and not hash maps) are used for relatively non-dynamic objects and then we keep the shape metadata on functions themselves (inline caches) which means property access becomes just a byte offset.

See https://v8.dev/blog/fast-properties