Better HN
topnewbestaskshowjobs
Log inSign up

pinaraf

153 karma · joined Feb 2, 2015 (11y ago) · 16 submissions

Submissions

1.

PostgreSQL copy-patch JIT, episode III(pinaraf.info ↗)

2 points · by pinaraf · 11mo ago · discuss

comment 1y ago · link · parent

And the latest driver available for Jetson Thor doesn't have the fixes for these two CVEs because they decided to fork their own driver...

3.

JIT: So you want to be faster than an interpreter on modern CPUs(pinaraf.info ↗)

170 points · by pinaraf · 1y ago · 63 comments

comment 2y ago · link · parent

The real difference is in the possible optimizations. If you consider the full scope of JIT compilation in for instance a web browser or the JVM, you could use copy and patch as a tier 0 compiler, and once really hot paths are identified, trigger a complete compiler with all the optimizer steps. Some optimizations are more complicated to implement with copy-patch, esp. if you can't use all the tricks described in the paper (for instance they use the ghccc calling convention to get a much finer register allocation, but from the documentation I don't think it's going to make it for PostgreSQL).

But as you say, yes, this enables people capable of writing C and reading assembly (or you have to be perfect and never have to go into gdb on your compiled code), and it makes the job so much faster and easier... Writing several machine code emitters is painful, and having the required optimization strategies for each ISA is quickly out of reach.

comment 2y ago · link · parent

Yeah, well, sorry, I should have been more explicit here: the issue is with PostgreSQL, not LLVM. The JIT compiler has to inject direct memory addresses, making the generated code specific to your query and process.

comment 2y ago · link · parent

Same for me, that's why I did this after finding out this research paper. With the proper compiler settings and small tricks you can remove some parts and already end up faster than the interpreter (because you remove some branches and a few memory accesses) and it's even possible to create "super-stencils" covering typical opcodes series and optimizing them further. Or the opposite, "sub-stencils" in order to do some loop unrolling for instance.

comment 2y ago · link · parent

Indeed, and right now it's the only possible way since it remains in a single session, doing otherwise would be very hard.

comment 2y ago · link · parent

Honestly I thought the same as you, then I wrote this, and I now understand it's going to be really hard to do. To make it very simple: there are pointers to query parts "leaking" everywhere across the execution engine. Removing them will require a significant overall of the execution engine, the planner and who knows what else. Even in a single session, two compiled queries will have different compiled code because of that (both llvm and my copyjit have to inject the adresses of various structs in asm code)

comment 2y ago · link · parent

Two parts: I did the benchmark on a laptop and didn't spend enough time forcing its runtime PM in a fixed state, I'll run a real pgbench on my desktop once I implement all required opcodes for it. And since JIT requires a minimum amount of time (about 300us on my tests), on such small runtimes this can quickly overcome the benefits.

comment 2y ago · link · parent

Author here. Thanks for submitting my article on hackernews. I'll do my best to answer any question.

11.

PostgreSQL – Using Row Level Security with a Django Application(pinaraf.info ↗)

2 points · by pinaraf · 9y ago · discuss

comment 10y ago · link · parent

PostgreSQL streaming : send disk diffs over network, raw binary, absolutely unusable if you don't have the same postgresql version on the other side Logical : send data diffs over network. Could be used for replication, but also audit or sending to different databases...

comment 10y ago · link · parent

Static checking ? Python 3.5 Asyncio ? Python 3.4

If these had been available in Python 3.2 or even better 3.0, the switch would have been far easier for corporate users that need benefits before accepting the cost of change...

comment 10y ago · link · parent

Well, it weights in favor of Python 2, and considering that until recently the incencitives for Python 3 were still light... It's not really about having users, but having the possibility of switching from CPython to PyPy if you face performance issues.

comment 10y ago · link · parent

So much work where there are many other solutions out there that don't have that limitation : PostgreSQL, several NoSQL databases...

comment 11y ago · link · parent

Debian sid, what else... On desktop, laptop, servers... Tools : QtCreator / KDevelop for C++, Netbeans for Java, vim or Kate for everything else