Hacker News new | ask | show | jobs
by crabbone 55 days ago
I recently interviewed for a company (for the purpose of not making this an advertisement, I will not name it) that uses FPGAs to speed up SQL queries. They claimed at least two orders of magnitude speedups for joins!

They also told me that they've started as a h/w shop and that they have competitors who are building ASICs rather than programming FPGAs to do the same (with, potentially, even more performance gains).

This completely changed the perspective for me. Before, I had this idea that if I need to optimize database performance, I'd first look at indices. Then, at how much memory is available to the database for various tasks. Only after that, I'd look at I/O performance, but, mostly, because of fsync configuration.

It wouldn't even appear to me as a possibility that the compute can become the culprit of optimization. But, apparently, it's a new hot thing.

* * *

From my experience with storage testing, which also included quite a bit of pg-bench exposure... My impression was this: the sort of query that is used for performance benchmark matters the most. It will define the optimization direction. Blindly trying to add or speed-up one resource or another is not going to be an efficient strategy. In the database world, there's this idea of an "ideal" benchmark. Without too much detail, it imagines an "ideal" business accounting back-end, the sort of queries it would have to execute. It defines an "ideal" unit that roughly encompasses one "sale", and then it measures how many such "sales" a business can perform per unit of time. This will translate into some ratio of selects / inserts / deletes / updates with some index hits and some linear searches etc. But it's all extremely vague and it's very hard to adapt this benchmark to the actual business needs of the database being tested.

There's also a question what to optimize for: the resource usage? the response speed? the concurrency? In some scenarios, I can see how storage would factor in, but there are also certainly scenarios where using a faster, in some sense, storage will not result in any meaningful gains.

3 comments

There was a whole bunch of work on GPUs for databases before GPUs became hard to get, which slowed it down a bit. A lot of the columnar database performance gain is from vectorization. Now which direct pcie DMA to GPU from NVMe this is even more attractive. FPGA seems much more work than GPU.
My understanding is that FPGAs are targeted not because they are ideal for the task, but because they are commercially available. As in: the customers may rent a VM from a major cloud vendor with FPGAs attached.

Trying to grow a business that relies on bespoke hardware in the age of cloud monopoly is an uphill battle.

Fun fact: Samsung made some SSDs ("SmartSSD") with an embedded programmable FPGA and one of the demos was using it along a modified version of postgresql to offload filtering and scans to the storage itself: https://pages.cs.wisc.edu/~jignesh/publ/SmartSSD.pdf https://www.xilinx.com/publications/product-briefs/xilinx-sm...

Though it looks like they didn't follow up on these and can't find them for sale

Yeah, I remember seeing those. It felt really promising. I have no idea why they didn't continue in this direction.

The company I talked to explained the use of FPGA by saying that FPGAs are offered by major cloud vendor, and so are a commercially viable direction. While making their own dedicated chips is not only a lot more expensive, but also doesn't have a lot of customers (people don't want to maintain their own h/w, especially of a bespoke variety). The bespoke part might be why Samsung didn't pursue the idea. Essentially, if eg. AWS doesn't buy this from you and makes it an offering that customers may reasonably rely on, it's too hard to sell.

Why would an FPGA speed up joins by two orders of magnitude?
Was my question too. Now, I have not tested the technology, so, I can't vouch for the veracity of the claim, but the answer I was given made sense. This is what it was: in the same way how a dedicated switch is a lot more efficient when dealing with IP packets than a general-purpose CPU is. In particular, comparison takes a lot less time because it is able to dramatically reduce the number of load operations. I found this paper: https://www.sfu.ca/~zhenman/files/C31-FCCM2023-SQL2FPGA.pdf (there's also a Github repo with some experimental code for Spark: https://github.com/SFU-HiAccel/SQL2FPGA) that does something similar.