ChrisHegarty commented on PR #12417: URL: https://github.com/apache/lucene/pull/12417#issuecomment-1638836015
Here's where I'm at, after spending the best part of the last three days hacking in this area - I'm on the fence about whether or not this is worth it. The current code and format are heavily optimised. The pattern plays to hotspot's auto-vectorization very well, generating AVX 2 instructions for quite a bit of the decoding. Along with the embedding of two integers into a single long, the prefix sum is quite efficient too. This is all to say that the bar is quite high to be "better". Since Panama is still incubating then we need a scalar fallback. This doesn't necessarily need to be as efficient as the current code, but it should be close (for some definition of close!). I personally find the Panama-ized code more straightforward and easier to reason about, but it requires a new format to work well. This format is superior for the Panama code, but less so for the scalar code. What bothers me even more is that we cannot easily integrate the prefix sum calculation into the unpack - as we run into Panama bounds check issues that make the performance very poor. The format proposed here works well for 128 bit widths, but won't for larger. So while I did proposed that we do favour 128, I'm less sure about committing to a new format that we know cannot be optimised further, without of course changing it again. I tried rewriting parts of the current code, retaining the format, and using Panama. It's possible, but buys us very little (the current code already largely compiles to AVX 2). In fact, heavily mixing AVX 512 for some parts of the decode with scalar for the tail bits results in horrid CPU slow downs. So we cannot even do that to get the "easy" bits of the current code to use AVX 512 rather than AVX2 :-( -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org