News for hackers. Stuff that matters.
Re:PostgreSQL Begins Adding LLVM JIT Support For Faster Perf... by tejasmanohar on Saturday April 07, 2018 @06:05PM (#16783267)
This is exciting. That said, it's important to note that this is unlikely to help much with most OLTP queries just looking up information quickly via indexed data. Where this could really shine is CPU-bound queries that are performing complex operations, where the SQL interpreter is actually a bottleneck.

I wonder if AWS will incorporate these improvements into Redshift, which is Postgres forked for OLAP use cases where this is far more prevalent. In the past, they haven't done a great job at this (ran into a float bug fixed upstream 5+ years ago), but this may be a big enough value proposition to justify the effort.

Re:PostgreSQL Begins Adding LLVM JIT Support For Faster Perf... by ankrgyl on Saturday April 07, 2018 @06:54PM (#16783508)
> I wonder if AWS will incorporate these improvements into Redshift, which is Postgres forked for OLAP use cases where this is far more prevalent. In the past, they haven't done a great job at this (ran into a float bug fixed upstream 5+ years ago), but this may be a big enough value proposition to justify the effort.

Redshift is forked from ParAccel, which was originally forked from Postgres several years ago. ParAccel has had code generation (via transpilation to C) since long before Amazon even purchased its source code. In other words, Redshift has had this feature since its inception, albeit via C-transpilation (compiled with GCC) not LLVM codegen.

In addition, Redshift's primary index is a column store which is particularly well-suited to code generation (you can inline and even vectorize expressions across rows, without hopping pointers in between rows). Postgres does not yet include a column store, but this piece of infrastructure is a big step in the right direction!

Re:PostgreSQL Begins Adding LLVM JIT Support For Faster Perf... by tejasmanohar on Saturday April 07, 2018 @10:06PM (#16784185)
Oh, neat! I hadn't heard of ParAccel. Suppose I'm missing some history here.
Re:PostgreSQL Begins Adding LLVM JIT Support For Faster Perf... by anarazel on Saturday April 07, 2018 @06:15PM (#16783322)
> That said, it's important to note that this is unlikely to help much with most OLTP queries just looking up information quickly via indexed data.

It'll definitely not help for that, at least for now. There's not yet any caching around JITed programs, which makes it completely unsuitable for OLTP. With caching (which requires some larger changes to postgres, which is why this won't be in v11), it's possible to observe some moderate gains.

> I wonder if AWS will incorporate these improvements into Redshift, which is Postgres forked for OLAP use cases where this is far more prevalent. In the past, they haven't done a great job at this (ran into a float bug fixed upstream 5+ years ago), but this may be a big enough value proposition to justify the effort.

I can't imagine them doing that. This uses a whole rewritten expression evaluation engine (introduced in v10), and a large number of infrastructure changes all over the executor (reimplementation of targetlist set returning functions, projection, ...). Not impossible, but certainly not something lightly done.

Re:PostgreSQL Begins Adding LLVM JIT Support For Faster Perf... by tejasmanohar on Saturday April 07, 2018 @06:29PM (#16783387)

  There's not yet any caching around JITed programs,
  which makes it completely unsuitable for OLTP.
Oh, I see. Thanks for clarifying! You mentioned it was merged. Does this mean it'll land in stable soon? Will it be behind a flag, or does the planner just know when to use it?

  I can't imagine them doing that.
RE: Redshift, That's very unfortunate :|. I suppose that's another downside of AWS forking vs. say Citus who moved to the extension model. Though, this would really be perfect for Redshift's use cases... so I guess we'll see.

--

This is a step in the right direction regardless, but I'm curious how many people are specifically using pure Postgres for large-scale OLAP models (not including occasionally running one-off queries on their OLTP data).

Re:PostgreSQL Begins Adding LLVM JIT Support For Faster Perf... by anarazel on Saturday April 07, 2018 @06:35PM (#16783421)
> Oh, I see. Thanks for clarifying! You mentioned it was merged. Does this mean it'll land in stable soon?

It has been merged into the master branch, which'll become PostgreSQL 11. First beta will be in a few weeks. Release is planned to be in September (early I'd hope).

> Will it be behind a flag, or does the planner just know when to use it?

There's cost based logic that chooses it, yes. See https://www.postgresql.org/docs/devel/static/jit-decision.ht...

You can change those if you want to force JIT on/off.

Re:PostgreSQL Begins Adding LLVM JIT Support For Faster Perf... by polskibus on Sunday April 08, 2018 @06:02AM (#16785437)
Isn't it against AWS interest to boost base postgresql or reduce differentiation against base postgresql? I wish they contributed to postgresql but that would weaken the lock-in of their core offering.
Re:PostgreSQL Begins Adding LLVM JIT Support For Faster Perf... by tejasmanohar on Sunday April 08, 2018 @12:29PM (#16786860)
Yes and no. Maybe yes for OLAP features but not in general, because Redshift isn’t fit for everything, and they have plain RDS Postgres offerings. Also, my original post questioned whether they would bring in improvements from Postgres core into their fork (Redshift)... in case you read the opposite.

I know the RDS team has contributed some fixes and the like to Postgres, but I’m unsure of their overall significance.

Re:PostgreSQL Begins Adding LLVM JIT Support For Faster Perf... by anarazel on Sunday April 08, 2018 @06:08PM (#16788754)
> I know the RDS team has contributed some fixes and the like to Postgres, but I’m unsure of their overall significance

Negligible.