Record Class StarlarkScript.Limits

java.lang.Object
java.lang.Record
org.microproxy.starlark.StarlarkScript.Limits
Record Components:
maxSteps - the positive maximum number of interpreter steps
timeout - the wall-clock limit, checked every few steps and by long-running builtins (regular expressions); non-positive millisecond values disable the deadline
maxAllocBytes - the most bytes of values a call may create, as StarlarkThread.getAllocatedBytes() estimates them; Long.MAX_VALUE for no limit
Enclosing class:
StarlarkScript

public static record StarlarkScript.Limits(long maxSteps, Duration timeout, long maxAllocBytes) extends Record
Bounds on each call into a script (and on running its top level). A call that goes past one fails with an EvalException, as any failing call does; the thread running it is not stopped otherwise.
  • Field Details

    • DEFAULT_MAX_ALLOC_BYTES

      public static final long DEFAULT_MAX_ALLOC_BYTES
      The default allocation budget, 256 MiB a call. It counts what a call creates, most of it garbage soon, not what it keeps, so it is not a heap size: it stops runaway allocation (a string repeated a billion times, a list or string doubling in a loop) long before that fills a heap, and leaves room for heavy but ordinary calls. A buffered body of the default 10 MiB counts about 20 MiB as a string (two bytes a character), so a call can copy it many times, and the heaviest tests of the ported standard library create up to 150 MB in one call (tables of thousands of formatting cases).
      See Also:
    • DEFAULT

      public static final StarlarkScript.Limits DEFAULT
      Ten million steps, five seconds and 256 MiB per call.
  • Constructor Details

    • Limits

      public Limits(long maxSteps, Duration timeout, long maxAllocBytes)
      Creates execution bounds.
      Parameters:
      maxSteps - the positive maximum number of interpreter steps
      timeout - the non-null wall-clock limit
      maxAllocBytes - the positive allocation budget, or Long.MAX_VALUE for none
      Throws:
      IllegalArgumentException - if maxSteps or maxAllocBytes is not positive
      NullPointerException - if timeout is null
    • Limits

      public Limits(long maxSteps, Duration timeout)
      Creates execution bounds with the default allocation budget.
      Parameters:
      maxSteps - the positive maximum number of interpreter steps
      timeout - the non-null wall-clock limit
  • Method Details

    • withMaxSteps

      public StarlarkScript.Limits withMaxSteps(long maxSteps)
      These bounds with another step limit.
      Parameters:
      maxSteps - the positive maximum number of interpreter steps
      Returns:
      the new bounds
    • withTimeout

      public StarlarkScript.Limits withTimeout(Duration timeout)
      These bounds with another wall-clock limit.
      Parameters:
      timeout - the limit; zero for none
      Returns:
      the new bounds
    • withMaxAllocBytes

      public StarlarkScript.Limits withMaxAllocBytes(long maxAllocBytes)
      These bounds with another allocation budget.
      Parameters:
      maxAllocBytes - the positive budget, or Long.MAX_VALUE for none
      Returns:
      the new bounds
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • maxSteps

      public long maxSteps()
      Returns the value of the maxSteps record component.
      Returns:
      the value of the maxSteps record component
    • timeout

      public Duration timeout()
      Returns the value of the timeout record component.
      Returns:
      the value of the timeout record component
    • maxAllocBytes

      public long maxAllocBytes()
      Returns the value of the maxAllocBytes record component.
      Returns:
      the value of the maxAllocBytes record component