<div dir="ltr">Hi All,<div><br></div><div>As discussed, I made changes in Utf8Validator[1] to use newly optimized Vector.slice API with constant slice index[2] </div><div>and see around 1.35x gain with this small change.</div><div><br></div><div>Baseline:</div><div>Utf8ValidatorBenchmark.utf8Validator                                                  twitter.json                                                                                                                                      N/A  thrpt    2     60140.708          ops/s</div><div><br></div><div>With optimization:</div><div>Utf8ValidatorBenchmark.utf8Validator                                                  twitter.json                                                                                                                                      N/A  thrpt    2     79926.621          ops/s  </div><div><br></div><div>Benchmarking system: AMD Ryzen 7 7840HS 8C 16T  AVX512</div><div><br></div><div>Please note my results are w.r.t to current JDK-mainline with and without patch[1] and [2].</div><div><br></div><div>Will create pull request against simdjson-java after some more validations and bumping its minimum build version to JDK-24.</div><div>I now plan to look at optimizing lookup tables using new Vector.selectFrom API[3]</div><div><br></div><div>Best Regards,</div><div>Jatin</div><div><br></div><div>[1] <a href="https://github.com/simdjson/simdjson-java/compare/main...jatin-bhateja:simdjson-java:jdk_24_changes#diff-3c7915a592a6357171dec9388a1c87ee46d96cd7e95ff7efb3fe58da3f1f5b6e">https://github.com/simdjson/simdjson-java/compare/main...jatin-bhateja:simdjson-java:jdk_24_changes#diff-3c7915a592a6357171dec9388a1c87ee46d96cd7e95ff7efb3fe58da3f1f5b6e</a></div><div>[2] <a href="https://github.com/openjdk/jdk/pull/24104">https://github.com/openjdk/jdk/pull/24104</a></div><div>[3] <a href="https://docs.oracle.com/en/java/javase/24/docs/api/jdk.incubator.vector/jdk/incubator/vector/Vector.html#selectFrom(jdk.incubator.vector.Vector,jdk.incubator.vector.Vector)">https://docs.oracle.com/en/java/javase/24/docs/api/jdk.incubator.vector/jdk/incubator/vector/Vector.html#selectFrom(jdk.incubator.vector.Vector,jdk.incubator.vector.Vector)</a></div><div><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Mon, Aug 4, 2025 at 9:50 PM Jatin Bhateja <<a href="mailto:jatinbha.cloud@gmail.com">jatinbha.cloud@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>

  
    
  
  <div>
    <p>Following JMH micro-benchmark shows 50x improvement in JSON
      structural character lookup using new Vector.selectFrom API which
      can operate on 128 byte lookup table.</p>
    <p><a href="https://github.com/ionutbalosin/jvm-performance-benchmarks/pull/105" target="_blank">https://github.com/ionutbalosin/jvm-performance-benchmarks/pull/105</a></p>
    <p>I plan to explore and modify existing UTF8Validator and
      StructuralIndexer components of <a href="https://github.com/simdjson/simdjson-java" rel="noreferrer" target="_blank">https://github.com/simdjson/simdjson-java</a> library.</p>
    <p>Best Regards,</p>
    <p>Jatin</p>
    <div><br>
    </div>
    <div>On 7/31/2025 8:33 PM, Charles Oliver
      Nutter wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="auto">The developer experimenting with vectors has been
        running 21, so I did suggest to him recently to try newer
        releases or dev builds. I'm out of office right now but hoping
        to spend some time in the next week running this through a
        profiler to see if other missed optimizations are interfering
        with the vectorized version of the code.
        <div dir="auto"><br>
        </div>
        <div dir="auto">I also pointed out the other vector-based json
          project to him that was suggested by Daniel. I'm hopeful we
          can get more out of this than we have seen so far once I can
          help profile and dig into optimized results a little bit more.</div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">There are many other places in JRuby where we
          could use this, such as for handling text transcoding. There
          may even be some Ruby language constructs that could be
          vectorized by JRuby's compiler. I wish I had more hours in the
          day to experiment with this!</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Mon, Jul 28, 2025, 22:40
          Paul Sandoz <<a href="mailto:paul.sandoz@oracle.com" target="_blank">paul.sandoz@oracle.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div>
            Hi Daniel,
            <div><br>
            </div>
            <div>Thanks for sharing. We have made progress optimizing
              the rearrange/selectFrom operations for UTF-8 related uses
              cases. The improvements were integrated into JDK release
              24 [0].</div>
            <div>
              <div>Further optimizations are in flight for slice
                operations with constant inputs [1], which I believe can
                simplify the referenced code and may further boost
                performance, but we need to verify.</div>
            </div>
            <div><br>
            </div>
            <div>Charlie, what version of the JDK are you using?</div>
            <div><br>
            </div>
            <div>Paul.</div>
            <div><br>
            </div>
            <div>[0] <a href="https://openjdk.org/jeps/489" rel="noreferrer" target="_blank">https://openjdk.org/jeps/489</a><br>
              <div>[1] <a href="https://github.com/openjdk/jdk/pull/24104" rel="noreferrer" target="_blank">https://github.com/openjdk/jdk/pull/24104</a></div>
              <div><br>
                <blockquote type="cite">
                  <div>On Jul 16, 2025, at 10:46 AM, Daniel Lemire <<a href="mailto:daniel@lemire.me" rel="noreferrer" target="_blank">daniel@lemire.me</a>>
                    wrote:</div>
                  <br>
                  <div>
                    <div>
                      <div>Good day Charles,</div>
                      <div><br>
                      </div>
                      <div>The following link might be relevant :</div>
                      <div><br>
                      </div>
                      <div><a href="https://github.com/simdjson/simdjson-java" rel="noreferrer" target="_blank">https://github.com/simdjson/simdjson-java</a><br>
                      </div>
                      <div><br>
                      </div>
                      <div>- Daniel</div>
                      <div><br>
                      </div>
                      <blockquote type="cite" id="m_158931083966738765m_5949170455508475308qt">
                        <div dir="ltr">
                          <div>After seeing similar work done for the C
                            version of the Ruby json standard library, I
                            suggested to the author that we could do the
                            same for JRuby using the Vector API. So he
                            went and did it!</div>
                          <div><br>
                          </div>
                          <div><a href="https://github.com/ruby/json/pull/824" rel="noreferrer" target="_blank">https://github.com/ruby/json/pull/824</a></div>
                          <div><br>
                          </div>
                          <div>The results are somewhat mixed;
                            performance of some cases is faster and
                            other cases is slower. We would love to get
                            input from anyone on this list interested in
                            seeing another real-world use case for the
                            Vector API.</div>
                          <div><br>
                          </div>
                          <div>I'm hopeful we can pump up these numbers
                            with some additional tweaking in JRuby and
                            json.</div>
                          <div><br>
                          </div>
                          <div>
                            <div dir="ltr">
                              <div dir="ltr">
                                <div><b>Charles Oliver Nutter</b></div>
                                <div><i>Architect and Technologist</i></div>
                                <div>Headius Enterprises</div>
                                <div><a href="https://www.headius.com/" rel="noreferrer" target="_blank">https://www.headius.com</a></div>
                                <div>
                                  <div><a href="mailto:headius@headius.com" rel="noreferrer" target="_blank">headius@headius.com</a></div>
                                </div>
                              </div>
                            </div>
                          </div>
                        </div>
                      </blockquote>
                      <div><br>
                      </div>
                    </div>
                  </div>
                </blockquote>
              </div>
              <br>
            </div>
          </div>
        </blockquote>
      </div>
    </blockquote>
  </div>

</blockquote></div>