Back to News
Advertisement
Advertisement

⚡ Community Insights

Discussion Sentiment

50% Positive

Analyzed from 589 words in the discussion.

Trending Topics

#jit#code#https#compiler#llvm#interpreter#org#compilation#compilers#writing

Discussion (22 Comments)Read Original on HackerNews

MaxBarracloughabout 2 hours ago
Reminds me of the 2024 blog post Look ma, I wrote a new JIT compiler for PostgreSQL [0]. Both articles lament that Postgres's LLVM-based JIT [1] takes a while to generate code.

> The rarity of JIT compilers makes me believe that implementing a JIT compiler historically was too difficult for it to be worthwhile.

That's only true of writing a JIT from scratch. There's no rarity of JITs, it's just that LLVM (and other frameworks) are often used. Every major interpreter has a JIT compiler. PCRE2 has a JIT compiler. There are JIT frameworks out there with much faster code-generation than LLVM: Cranelift, GNU Lightning, Mir. I doubt they could do code-generation faster than a custom copy-and-patch JIT, but they'd be much faster than LLVM.

[0] https://www.pinaraf.info/2024/03/look-ma-i-wrote-a-new-jit-c... , discussed: https://news.ycombinator.com/item?id=39742916

[1] https://www.postgresql.org/docs/current/jit-reason.html

pjmlpabout 1 hour ago
The original Dartmouth BASIC had a JIT like approach, the REPL would compile to machine code before execution.

It was the limits of 8 bit home computers hardware that made the interpreter version be more widely known.

Same to Lisp, Smalltalk, and many other languages.

Fully agree with you.

BoingBoomTschakabout 1 hour ago
A few other small and fast JITs: https://github.com/zherczeg/sljit (used by libpcre), https://github.com/asmjit/asmjit (RPCS3 and FBGEMM) and https://webkit.org/blog/5852/introducing-the-b3-jit-compiler... (only used by JSC in Webkit, I think)
glum64about 2 hours ago
Uhm, Common Lisp, where JIT is not only available but is also manageable: the programmer can decide what deserves to be compiled and what does not.

Besides run time, JIT is available also when the code is compiled or loaded for execution (i.e., do you have a compilation or loading speed-up in mind? no problem, you can also compile that speed-up into native machine code, and so ad infinitum...).

hamilyon2about 1 hour ago
It uses copy-and-patch compilation to archive that
varjagabout 1 hour ago
There’s been a meme circulating about how AI doesn’t help because “code was never the hard part.” I think that’s true in some domains, but in others, writing the code absolutely was the hard part. JIT compilers are a great example of that.
asdfsa3243 minutes ago
Anyone who thinks AI is good with writing code that is hard to write for the operator, not due to lack of basic software engineering know how but complexity of the domain, either has access to models beyond what is available to the public or is completely lost.

I believe this because every time I use AI for domains that I consider myself above competent, if it is anything beyond UI components or a simple CRUD endpoints, I cringe at the quality of what it generates.

This has made me to be extremely cautious of starting working in a new domain with AI if I want anything beyond throw away quick hacks or junk, shy of quick bug fixes perhaps.

glenjaminabout 3 hours ago
pgrust sounds very interesting, but with the deep changes there’s no viable path to upstream it - is the end goal to be robust enough that it’ll get wide adoption?
FiberBundle33 minutes ago
Is it really interesting though? It's essentially just vibe-coded by people who are unqualified for this kind of work. One of the authors claimed that what qualified them was having worked on a large-scale postgres cluster; they never actually worked on databases or compilers.
roschdalabout 3 hours ago
JIT compilation is unsecure.
asdfsa32about 2 hours ago
You're entirely correct because JIT requires violating Write xor Execute security policy. This is the reason on iOS, it is limited to Apple shipped software.

https://en.wikipedia.org/wiki/W%5EX

shaknaabout 2 hours ago
The wiki page mentions this is only a minor problem. Because everyone just writes, then switches and executes.
asdfsa32about 1 hour ago
But this means that you have to decide who is allowed to switch.
sebzim4500about 2 hours ago
Maybe, but surely there are users who are willing to trust all users of their db instance.
asdfsa32about 2 hours ago
The issue is that it restricts from locking-down and securing the system with Write xor Execute memory. So it has system wide implication.

https://en.wikipedia.org/wiki/W%5EX

PhilipRomanabout 1 hour ago
W^X is typically per mapping, not per memory page and does not interfere with JIT compilation.
dennis16384about 2 hours ago
It is the core of ClickHouse for example, for many years. Is it secure enough in your opinion?
JackSlateurabout 1 hour ago
In rust, is jit equivalent to an "unsafe" block ?
pjmlp43 minutes ago
Machine code is insecure, we should all run interpreted code in a formally verified interpreter.

Alternatively, only allow for the execution of cryptographly signed static linked binaries, this naturally includes the interpreter above.