You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2025/10/31 14:02:50 UTC

[PR] PROTOTYPE: manually unroll vlq decoder loop [arrow-rs]

alamb opened a new pull request, #8757:
URL: https://github.com/apache/arrow-rs/pull/8757

   # Which issue does this PR close?
   
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax.
   
   - Follow on to https://github.com/apache/arrow-rs/pull/8742 from @etseidl 
   
   # Rationale for this change
   
   Per https://github.com/apache/arrow-rs/pull/8742#pullrequestreview-3400812414 let's get crazt and see if manually unrolling the vlq decoder (hot loop) will help or hurt performance
   
   # What changes are included in this PR?
   
   Manually unroll the loop
   
   # Are these changes tested?
   
   CI passes . I am running benchmarks
   
   # Are there any user-facing changes?
   
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   
   If there are any breaking changes to public APIs, please call them out.
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PROTOTYPE: manually unroll vlq decoder loop [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8757:
URL: https://github.com/apache/arrow-rs/pull/8757#issuecomment-3475221386

   🤖: Benchmark completed
   
   <details><summary>Details</summary>
   <p>
   
   
   ```
   group                             alamb_vlq_opt                          main
   -----                             -------------                          ----
   decode parquet metadata           1.00      9.9±0.03µs        ? ?/sec    1.05     10.4±0.78µs        ? ?/sec
   decode parquet metadata (wide)    1.00     43.4±0.28ms        ? ?/sec    1.05     45.7±2.75ms        ? ?/sec
   open(default)                     1.00      9.7±0.03µs        ? ?/sec    1.04     10.1±0.06µs        ? ?/sec
   open(page index)                  1.14    199.4±1.13µs        ? ?/sec    1.00    174.7±0.81µs        ? ?/sec
   ```
   
   
   </p>
   </details>
   
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PROTOTYPE: manually unroll vlq decoder loop [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #8757:
URL: https://github.com/apache/arrow-rs/pull/8757#issuecomment-3475185242

   Flamegraph showing the amount of time spent in `read_vlq` (about 24% of the total including drop time) with the latest parser. This is the same data as the "wide" metadata benchmark. 
   
   <img width="1337" height="576" alt="Screen Shot 2025-10-31 at 4 04 48 PM" src="https://github.com/user-attachments/assets/3ba469f7-62ac-4105-84f9-3aaa44b53fe3" />
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PROTOTYPE: manually unroll vlq decoder loop [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8757:
URL: https://github.com/apache/arrow-rs/pull/8757#issuecomment-3476133421

   🤖: Benchmark completed
   
   <details><summary>Details</summary>
   <p>
   
   
   ```
   group                             alamb_vlq_opt                          main
   -----                             -------------                          ----
   decode parquet metadata           1.01      9.8±0.04µs        ? ?/sec    1.00      9.7±0.02µs        ? ?/sec
   decode parquet metadata (wide)    1.02     43.1±0.75ms        ? ?/sec    1.00     42.4±0.60ms        ? ?/sec
   open(default)                     1.03      9.7±0.05µs        ? ?/sec    1.00      9.5±0.03µs        ? ?/sec
   open(page index)                  1.15    199.2±0.77µs        ? ?/sec    1.00    173.7±0.53µs        ? ?/sec
   ```
   
   
   </p>
   </details>
   
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PROTOTYPE: manually unroll vlq decoder loop [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8757:
URL: https://github.com/apache/arrow-rs/pull/8757#issuecomment-3475218619

   🤖 `./gh_compare_arrow.sh` [Benchmark Script](https://github.com/alamb/datafusion-benchmarking/blob/main/scripts/gh_compare_arrow.sh) Running
   Linux aal-dev 6.14.0-1017-gcp #18~24.04.1-Ubuntu SMP Tue Sep 23 17:51:44 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
   Comparing alamb/vlq_opt (d67a9a1550b80ff8f051470a0eb4b10404620416) to bac0cb57af36f0c025696db146eccea8f3f469cb [diff](https://github.com/apache/arrow-rs/compare/bac0cb57af36f0c025696db146eccea8f3f469cb..d67a9a1550b80ff8f051470a0eb4b10404620416)
   BENCH_NAME=metadata
   BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental --bench metadata 
   BENCH_FILTER=
   BENCH_BRANCH_NAME=alamb_vlq_opt
   Results will be posted here when complete
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PROTOTYPE: manually unroll vlq decoder loop [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8757:
URL: https://github.com/apache/arrow-rs/pull/8757#issuecomment-3480547473

   benchmarks don't show a noticable difference


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PROTOTYPE: manually unroll vlq decoder loop [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb closed pull request #8757: PROTOTYPE: manually unroll vlq decoder loop
URL: https://github.com/apache/arrow-rs/pull/8757


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PROTOTYPE: manually unroll vlq decoder loop [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #8757:
URL: https://github.com/apache/arrow-rs/pull/8757#issuecomment-3474131237

   FWIW I tried using
   ```
   // byte N
   let byte = self.read_byte()?;
   if byte & 0x80 == 0 {
       return Ok(in_progress | ((byte as u64) << N*7));
   }
   in_progress |= ((byte & 0x7f) as u64) << N*7;
   ```
   as the unit of work and that worked a bit better on my laptop. No need to mask `byte` if we already know the MSB is 0.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PROTOTYPE: manually unroll vlq decoder loop [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8757:
URL: https://github.com/apache/arrow-rs/pull/8757#issuecomment-3474961913

   Once I get some benchmark numbers I will rework to use your pattern @etseidl  -- maybe even try with some const functions to avoid the repetition


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PROTOTYPE: manually unroll vlq decoder loop [arrow-rs]

Posted by "etseidl (via GitHub)" <gi...@apache.org>.
etseidl commented on PR #8757:
URL: https://github.com/apache/arrow-rs/pull/8757#issuecomment-3473902094

   If you want to go truly crazy there's https://arxiv.org/html/2403.06898v1 🤣 Pretty clever.


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] PROTOTYPE: manually unroll vlq decoder loop [arrow-rs]

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on PR #8757:
URL: https://github.com/apache/arrow-rs/pull/8757#issuecomment-3476128173

   🤖 `./gh_compare_arrow.sh` [Benchmark Script](https://github.com/alamb/datafusion-benchmarking/blob/main/scripts/gh_compare_arrow.sh) Running
   Linux aal-dev 6.14.0-1017-gcp #18~24.04.1-Ubuntu SMP Tue Sep 23 17:51:44 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
   Comparing alamb/vlq_opt (d67a9a1550b80ff8f051470a0eb4b10404620416) to bac0cb57af36f0c025696db146eccea8f3f469cb [diff](https://github.com/apache/arrow-rs/compare/bac0cb57af36f0c025696db146eccea8f3f469cb..d67a9a1550b80ff8f051470a0eb4b10404620416)
   BENCH_NAME=metadata
   BENCH_COMMAND=cargo bench --features=arrow,async,test_common,experimental --bench metadata 
   BENCH_FILTER=
   BENCH_BRANCH_NAME=alamb_vlq_opt
   Results will be posted here when complete
   


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org