Show HN: Ibex a C++ engine for Polars and standalone DSL

ibexlang.org

23 points by Bootvis 7 hours ago

IbexEngine is an alternative execution engine for Polars, using an approach similar to cuDF's. Write a lazy Polars pipeline, collect() them with the IbexEngine() and get a Polars DataFrame:

    from ibex_polars import IbexEngine

    df = query.collect(engine=IbexEngine())  # df: pl.DataFrame

The results below are against Polars 2.2 streaming:

- h2o groupby: 2.2x faster on 1 core, 1.6x on 8

- PDS-H SF-10: 5–8% faster (total 6.53s vs 6.83s on 8 cores)

- h2o joins: 27% faster on 1 core, 13% slower on 8

Of 3,519 queries from Polars' test suite, 2,320 match Polars exactly. The remaining 1,199 are rejected. Ibex doesn't support columns containing lists and supports a smaller number of int types, forcing most of the refusals. In practice, this shouldn't matter too much. Unsupported plans raise NotImplementedError before query execution so you don't waste time with late runtime errors. For a quick start:

    try:

        df = query.collect(engine=IbexEngine())

    except NotImplementedError:

        df = query.collect(engine="streaming")

Caveats: experimental, single person, LLM's, and pinned to exactly Polars 2.2.0 because it uses Polars' internal plan format. Wheels for Linux, Windows and macOS:

    pip install ibex-polars --find-links https://github.com/bobjansen/Ibex/releases/expanded_assets/v0.6.0

The Ibex DSL itself is a statically typed DataFrame language (without loops) written in C++, with a REPL and C++23 code generation. I think Ibex itself is amazing but the Polars engine is the quickets way to try it on your existing projects.

yunnpp 5 hours ago

As somebody who uses Pandas/scipy regularly, what is the advantage of using this and how does performance compare? Sounds like compiling the ibex script or whatever to C++ is the main feature, but what's the performance vs numpy?

  • Bootvis 5 hours ago

    I originally built this with just the idea of providing a simpler syntax than can be provided in a host language. When writing code with libraries like Polars or pandas, you have to write valid Python. This forces you to put quotes around every column name for example. With Ibex you can just write bare column names, from the website:

        ibex> ticks[select { avg_price = mean(price), traded = sum(volume) }, by symbol, order { avg_price desc }];
    

    I strived to be more compact and easier to write than Polars/pandas and SQL but more readable than APL/J/K.

    Early on, I just wanted it to be somewhat fast, by picking reasonable data structures and writing it in C++ I sort of got there but I soon realised there was more to be gained. Coding agents became quite good at optimisation as well, so the last couple of months I have been squeezing out performance. I think this was quite successful, for in memory tasks and up to 8 cores Ibex turned out to be one of the speedier options. I have an overview[1] but I didn’t want to lead with it because these are homegrown, Ibex is particularly well adjusted to what I found interesting and added, and honest benchmarking isn’t easy and I don’t want to give an overly optimistic picture. I haven’t compared to numpy yet because I focus on tables, doing something interesting with matrices is in the pipeline and then I will compare against numpy as well. So to answer your question: Ibex is fast for many workloads but YMMV.

    [1]: https://ibexlang.org/benchmarks.html

ozgrakkurt 6 hours ago

Why not a table with total data size, selection percentage and timing? Size per time? What is 2x supposed to mean

  • Bootvis 6 hours ago

    I don’t quite follow, would you like to see filter performance for various tables? I did those tests as well but for sharing I focus on 3rd party benchmark suites, those are harder to game.

    2x faster => 50% runtime

    • ozgrakkurt 5 hours ago

      If polars has a performance cliff in some configuration of a query, then I can put vanilla datafusion against it and say it is 50x faster. There is no point in comparing them like this to each other.

      If you said it can filter through 20GB of data in a second on a single thread, then that is really good regardless except if the computer has 400GB of ram then it matters if it was cached beforehand etc. It is just not easy to do benchmarks.

      For example: https://rocksdb.org/blog/2021/12/29/ribbon-filter.html

      It is absurd that we are not even close to having this quality 6 years after these things were done and we even have tireless LLMs to use now. There is no excuse.

      This kind of writing in the OP is not about knowledge or learning or technicality of something it is more like a tooth paste commercial on tv with some numbers on the side. AHH wait, those commercials also have the same numbers.

      • Bootvis 5 hours ago

        I invite you to have a look at the benchmarking page[1] where different benchmarking suites are measured at different core counts and sizes. Note that the PDS-H suite originates from Polars and trust me that I have ran on different configurations to sanity check these results.

        [1]: https://ibexlang.org/benchmarks.html

        • ozgrakkurt 4 hours ago

          This is great, no offence to you. But it just hard for me get any value out of it without having some rationale and then hardware limit based benchmark after that and some writing that explains what is happening why.

          Benchmarks aren't the end goal but it should be a tool in explaining what is happening imo.

          This is not just for measuring tools against each other but also getting something out of the writing as a group so we can understand more.

          For example if you have some queries that stress group-by performance in a way and you are doing group by in a better way then you can show that and give a rationalization of results and explain what is done differently to get such a result.

          I don't mean to bash on your achievement, it is really great but I genuinely think that one writing like that would be more than a comprehensive benchmark dump.

          For example: https://pivotlake.io/blog/know-your-limit-faster-top-k-aggre...

          This is a good example for the rationalization part but not measurements imo.

          In the end it is impossible to build on these systems unless the person building on top has actual understanding of what is happening and why. It feels like we are just dumping around numbers and ideas whitout any connection between things.