Very interesting! It seems that many of us have tried to optimize the thrift
parsing. I also conducted a similar experiment, using AI to understand what
arrow-rs has done and ended up writing a new C++ footer structure with lazy
parsing: https://github.com/apache/arrow/pull/55111. However, I've only
observed a maximum speedup around 2.5X based on my workload on my
macOS laptop.

On Tue, Nov 24, 2026 at 8:08 AM Alkis Evlogimenos via dev <
[email protected]> wrote:

> Thanks for doing this experiments Antoine! This approach ties well with
> Wills jump index for footer.
>
> Your results are similar to what we also have internally. This is valid
> strategy for wide tables and partial reads but it doesn't match the footer
> v3 proposals compactness and speed. Parquet is too good at describing
> Parquet metadata!
>
>
> On Mon, Nov 23, 2026 at 5:19 PM PRATEEK GAUR <[email protected]> wrote:
>
> > Hi Antoine,
> >
> > This is great!
> >
> > >  ColumnChunk parsing is skipped and a placeholder is recorded
> > > that points at the range of Thrift
> >
> > Haven't gone through all the details of your implementation yet.
> > But I can say I did try a similar(maybe the exact) idea recently and
> > it gave similar magnitude of improvement.
> >
> > This is a very promising optimization and absolutely should be
> > implemented. It really helps with those large footer with multi
> > row groups and large number of columns.
> >
> > Best
> > Prateek
> >
> > On Mon, Nov 23, 2026 at 8:08 AM Antoine Pitrou <[email protected]>
> wrote:
> >
> > >
> > > Hello,
> > >
> > > In the spirit of trying to make wide Parquet files faster to read when
> > > projecting onto a couple columns, I have been experimenting with lazy
> > > parsing of Thrift ColumnChunk structures.
> > >
> > > The idea is that, when parsing the Parquet footer, ColumnChunk parsing
> > > is skipped and a placeholder is recorded that points at the range of
> > > Thrift bytes that encode the ColumnChunk. Then, when the ColumnChunk
> > > is actually required, the range of bytes is decoded on the fly and the
> > > decoded ColumnChunk is stored instead.
> > >
> > > Thrift being a stack-based bytecode format, this is not trivial. Thrift
> > > C++ comes with a generic skip() function that is too slow. However, a
> > > hand-written skipping function (still generic but carefully tuned)
> > > turns out to give good results.
> > >
> > > You can find a PoC branch on Arrow C++ here:
> > > https://github.com/apache/arrow/compare/main...pitrou:thrift-exp
> > >
> > > Here are some benchmark results:
> > > * before:
> > https://gist.github.com/pitrou/772001440bdb3ed38279c075e34e59eb
> > > * after:
> https://gist.github.com/pitrou/86e4e6ce89810252f9943e31722591b0
> > >
> > > I got an AI to distill those results as a Markdown table, hopefully
> > > the numbers are right 🙃:
> > > https://gist.github.com/pitrou/6e668f747edc50a5eec63841c8a6b5d3
> > >
> > > The results should be almost self-explanatory: `ReadFileMetadata`
> > > just parses the Parquet footer while `ReadFileAndColumnMetadata`
> > > also accesses a subset of the column chunk metadata, triggering
> > > lazy parsing.
> > >
> > > Bottom line:
> > >
> > > 1. Lazy parsing can yield up to a 9x speedup with 100,000 column
> > >     chunks in the file.
> > >
> > > 2. Selecting (== decoding the metadata for) a moderate amount of
> > >     columns ("sel=5%") still yields interesting speedups, up to 5x.
> > >
> > > 3. Selecting all columns, on the other hand, is significantly slower
> > >     (up to 30%) because the initial Thrift skipping adds to the total
> > >     footer parsing time.
> > >
> > > Profiling the most extreme benchmarking cases gives interesting
> insights:
> > >
> > > 1. For `ReadFileMetadata/num_columns:1000/num_row_groups:100`, Thrift
> > >     decoding and skipping accounts for 87% of the benchmark time; this
> > >     implies that Thrift is really the bottleneck when there is a large
> > >     number of row groups *and* columns;
> > >
> > > 2. However, for `ReadFileMetadata/num_columns:1000/num_row_groups:1`,
> > >     Thrift deserialization is only 17% of the benchmark time - the rest
> > >     is Parquet C++ schema construction and destruction. Therefore,
> > >     more work may be warranted in the Parquet C++ codebase itself in
> > >     order to reduce inefficiencies, regardless of whether Thrift is
> > >     involved at all.
> > >
> > >
> > > A couple technical details about the PoC:
> > >
> > > * I had to modify the Thrift-generated C++ files, so this is definitely
> > >    not maintainable. A clean implementation probably requires a custom
> > >    C++ Thrift parser (which would also probably be faster).
> > >
> > > * The core Thrift skipping function is non-recursive and allows for
> > >    aggressive inlining (*). On my machine (a AMD Zen 2 CPU), it seems
> to
> > >    skip at around 1.5 GB/s.
> > >
> > >    (*) See `SkipListOfStructCompact` in `parquet_types.tcc`.
> > >
> > >
> > > This shouldn't discourage more radical Parquet footer experiments, but
> > > may provide interesting optimization opportunities in the shorter term,
> > > including with existing Parquet datasets.
> > >
> > > Regards
> > >
> > > Antoine.
> > >
> > >
> >
>

Reply via email to