Class Simd

java.lang.Object
org.microproxy.simd.Simd

public final class Simd extends Object
Byte loops on the proxy's hot paths, with an optional SIMD implementation.

The SIMD version uses the Vector API, which is still an incubating JDK module. It is used only when the JVM runs with --add-modules jdk.incubator.vector (the JVM then prints an incubator warning at startup). The system property microproxy.simd can be auto (the default: use SIMD when the module is present), true (warn if it is not), or false (never). Without the module the scalar version runs, so the proxy needs nothing beyond JDK 21.

Public for use across MicroProxy's packages; not a supported API.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
    The operations, in scalar and SIMD flavours.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    indexOf(byte[] a, int from, int to, byte value)
    Finds the first matching byte within the specified range.
    static boolean
    Reports whether the selected implementation uses SIMD.
    static Simd.Ops
    ops()
    Returns the implementation in use.
    static Simd.Ops
    Returns the scalar implementation, always available.
    static Simd.Ops
    Returns the SIMD implementation, or null if the Vector API module is not present.
    static void
    xorMask(byte[] a, int off, int len, int mask)
    Applies the repeating four-byte WebSocket mask to an array range.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • ops

      public static Simd.Ops ops()
      Returns the implementation in use.
      Returns:
      the implementation in use
    • scalar

      public static Simd.Ops scalar()
      Returns the scalar implementation, always available.
      Returns:
      the scalar implementation, always available
    • vector

      public static Simd.Ops vector()
      Returns the SIMD implementation, or null if the Vector API module is not present.
      Returns:
      the SIMD implementation, or null if the Vector API module is not present
    • isVectorized

      public static boolean isVectorized()
      Reports whether the selected implementation uses SIMD.
      Returns:
      whether SIMD is in use
    • indexOf

      public static int indexOf(byte[] a, int from, int to, byte value)
      Finds the first matching byte within the specified range.
      Parameters:
      a - the byte array to search
      from - the first array index, inclusive
      to - the last array index, exclusive
      value - the byte value to find
      Returns:
      the first matching index, or -1 if no byte matches
    • xorMask

      public static void xorMask(byte[] a, int off, int len, int mask)
      Applies the repeating four-byte WebSocket mask to an array range.
      Parameters:
      a - the byte array to modify
      off - the first byte offset to modify
      len - the number of bytes to modify
      mask - the four-byte mask, applied most significant byte first