Package org.microproxy.starlark
Record Class StarlarkScript.Limits
java.lang.Object
java.lang.Record
org.microproxy.starlark.StarlarkScript.Limits
- Record Components:
maxSteps- the positive maximum number of interpreter stepstimeout- the wall-clock limit, checked every few steps and by long-running builtins (regular expressions); non-positive millisecond values disable the deadlinemaxAllocBytes- the most bytes of values a call may create, asStarlarkThread.getAllocatedBytes()estimates them;Long.MAX_VALUEfor 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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StarlarkScript.LimitsTen million steps, five seconds and 256 MiB per call.static final longThe default allocation budget, 256 MiB a call. -
Constructor Summary
ConstructorsConstructorDescriptionCreates execution bounds with the default allocation budget.Creates execution bounds. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.longReturns the value of themaxAllocBytesrecord component.longmaxSteps()Returns the value of themaxStepsrecord component.timeout()Returns the value of thetimeoutrecord component.final StringtoString()Returns a string representation of this record class.withMaxAllocBytes(long maxAllocBytes) These bounds with another allocation budget.withMaxSteps(long maxSteps) These bounds with another step limit.withTimeout(Duration timeout) These bounds with another wall-clock limit.
-
Field Details
-
DEFAULT_MAX_ALLOC_BYTES
public static final long DEFAULT_MAX_ALLOC_BYTESThe 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
Ten million steps, five seconds and 256 MiB per call.
-
-
Constructor Details
-
Limits
Creates execution bounds.- Parameters:
maxSteps- the positive maximum number of interpreter stepstimeout- the non-null wall-clock limitmaxAllocBytes- the positive allocation budget, orLong.MAX_VALUEfor none- Throws:
IllegalArgumentException- ifmaxStepsormaxAllocBytesis not positiveNullPointerException- iftimeoutis null
-
Limits
Creates execution bounds with the default allocation budget.- Parameters:
maxSteps- the positive maximum number of interpreter stepstimeout- the non-null wall-clock limit
-
-
Method Details
-
withMaxSteps
These bounds with another step limit.- Parameters:
maxSteps- the positive maximum number of interpreter steps- Returns:
- the new bounds
-
withTimeout
These bounds with another wall-clock limit.- Parameters:
timeout- the limit; zero for none- Returns:
- the new bounds
-
withMaxAllocBytes
These bounds with another allocation budget.- Parameters:
maxAllocBytes- the positive budget, orLong.MAX_VALUEfor none- Returns:
- the new bounds
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
maxSteps
public long maxSteps()Returns the value of themaxStepsrecord component.- Returns:
- the value of the
maxStepsrecord component
-
timeout
Returns the value of thetimeoutrecord component.- Returns:
- the value of the
timeoutrecord component
-
maxAllocBytes
public long maxAllocBytes()Returns the value of themaxAllocBytesrecord component.- Returns:
- the value of the
maxAllocBytesrecord component
-