Class QueryPerformanceRecorder
- All Implemented Interfaces:
Serializable
QueryPerformanceNugget
instances.
Thread-safety note: This used to be thread-safe only by virtue of using a thread-local instance. Now it's aggressively synchronized so we can abort it from outside the "owner" thread.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
This is for use by the RemoteQueryProcessor.static void
Clear any previously set callsite.boolean
endQuery()
This is for use by the RemoteQueryProcessor.static void
Deprecated.No longer used.static String
static long
static long
static QueryPerformanceRecorder
io.deephaven.enterprise.auth.UserContext
static long
Get the total bytes of pool-allocated memory attributed to this thread viarecordPoolAllocation(Supplier)
.io.deephaven.enterprise.auth.UserContext
static long
static long
getState()
Return the query's current statestatic void
recordFirstTimeDataRead
(long durationNanos) static <RESULT_TYPE>
RESULT_TYPErecordPoolAllocation
(Supplier<RESULT_TYPE> operation) Record a single-threaded operation's allocations as "pool" allocated memory attributable to the current thread.static void
recordRepeatedDataRead
(long durationNanos) static void
static boolean
Attempt to compute and set the thread local callsite so that invocations ofgetCallerLine()
will not spend time trying to recompute.static boolean
setCallsite
(String callsite) Attempt to set the thread local callsite so that invocations ofgetCallerLine()
will not spend time trying to recompute.void
Deprecated.Recording the caller line is now enabled for all nuggets by default.void
startQuery
(String description) Deprecated.void
startQuery
(String description, io.deephaven.enterprise.auth.UserContext primaryUserContext, io.deephaven.enterprise.auth.UserContext operationUserContext) This is for use by the RemoteQueryProcessor.static void
withNugget
(String name, long inputSize, com.fishlib.base.Procedure.Nullary r) Surround the given code with a Performance Nuggetstatic <T> T
withNugget
(String name, long inputSize, Supplier<T> r) Surround the given code with a Performance Nuggetstatic void
withNugget
(String name, com.fishlib.base.Procedure.Nullary r) Surround the given code with a Performance Nuggetstatic <T> T
withNugget
(String name, Supplier<T> r) Surround the given code with a Performance Nuggetstatic <R,
ExceptionType extends Exception>
RwithNuggetThrowing
(String name, long inputSize, com.fishlib.base.Function.ThrowingNullary<R, ExceptionType> r) Surround the given code with a Performance Nuggetstatic <T extends Exception>
voidwithNuggetThrowing
(String name, long inputSize, com.fishlib.base.Procedure.ThrowingNullary<T> r) Surround the given code with a Performance Nuggetstatic <R,
ExceptionType extends Exception>
RwithNuggetThrowing
(String name, com.fishlib.base.Function.ThrowingNullary<R, ExceptionType> r) Surround the given code with a Performance Nuggetstatic <T extends Exception>
voidwithNuggetThrowing
(String name, com.fishlib.base.Procedure.ThrowingNullary<T> r) Surround the given code with a Performance Nugget
-
Constructor Details
-
QueryPerformanceRecorder
public QueryPerformanceRecorder()
-
-
Method Details
-
getInstance
-
resetInstance
public static void resetInstance() -
startQuery
public void startQuery(String description, io.deephaven.enterprise.auth.UserContext primaryUserContext, io.deephaven.enterprise.auth.UserContext operationUserContext) This is for use by the RemoteQueryProcessor. It should only be used by user classes in local queries.- Parameters:
description
- the query's Action nameprimaryUserContext
- the query's user contextoperationUserContext
- the client's user context
-
startQuery
Deprecated.startQuery for backwards-compatibility in case any customer code happens to use it- Parameters:
description
- the query's Action name
-
abortQuery
public void abortQuery()This is for use by the RemoteQueryProcessor. It should only be used by user classes in local queries. -
getState
Return the query's current state- Returns:
- the query's state or null if it isn't initialized yet
-
endQuery
public boolean endQuery()This is for use by the RemoteQueryProcessor. It should only be used by user classes in local queries. -
getNugget
- Parameters:
name
- the nugget name- Returns:
- A new QueryPerformanceNugget to encapsulate user query operations. done() must be called on the nugget.
-
getNugget
- Parameters:
name
- the nugget nameinputSize
- the nugget's input size- Returns:
- A new QueryPerformanceNugget to encapsulate user query operations. done() must be called on the nugget.
-
getOuterNugget
-
getOuterMostNugget
-
getQueryLevelPerformanceData
-
getPrimaryUserContext
public io.deephaven.enterprise.auth.UserContext getPrimaryUserContext() -
getOperationUserContext
public io.deephaven.enterprise.auth.UserContext getOperationUserContext() -
getOperationLevelPerformanceData
-
getTimingResultsAsTable
-
flushLocalInstance
Deprecated.No longer used. -
showLineNumbers
Deprecated.Recording the caller line is now enabled for all nuggets by default. -
recordPoolAllocation
public static <RESULT_TYPE> RESULT_TYPE recordPoolAllocation(@NotNull Supplier<RESULT_TYPE> operation) Record a single-threaded operation's allocations as "pool" allocated memory attributable to the current thread.- Parameters:
operation
- The operation to record allocation for- Returns:
- The result of the operation.
-
getPoolAllocatedBytesForCurrentThread
public static long getPoolAllocatedBytesForCurrentThread()Get the total bytes of pool-allocated memory attributed to this thread viarecordPoolAllocation(Supplier)
.- Returns:
- The total bytes of pool-allocated memory attributed to this thread.
-
recordFirstTimeDataRead
public static void recordFirstTimeDataRead(long durationNanos) -
recordRepeatedDataRead
public static void recordRepeatedDataRead(long durationNanos) -
getFirstTimeDataReads
public static long getFirstTimeDataReads() -
getFirstTimeDataReadNanos
public static long getFirstTimeDataReadNanos() -
getRepeatedDataReads
public static long getRepeatedDataReads() -
getRepeatedDataReadNanos
public static long getRepeatedDataReadNanos() -
getCallerLine
-
withNugget
Surround the given code with a Performance Nugget- Parameters:
name
- the nugget namer
- the stuff to run
-
withNugget
Surround the given code with a Performance Nugget- Parameters:
name
- the nugget namer
- the stuff to run- Returns:
- the result of the stuff to run
-
withNuggetThrowing
public static <T extends Exception> void withNuggetThrowing(String name, com.fishlib.base.Procedure.ThrowingNullary<T> r) throws T Surround the given code with a Performance Nugget- Parameters:
r
- the stuff to run- Throws:
T
- exception of type T
-
withNuggetThrowing
public static <R,ExceptionType extends Exception> R withNuggetThrowing(String name, com.fishlib.base.Function.ThrowingNullary<R, ExceptionType> r) throws ExceptionTypeSurround the given code with a Performance Nugget- Parameters:
name
- the nugget namer
- the stuff to run- Returns:
- the result of the stuff to run
- Throws:
ExceptionType
- exception of type ExceptionType
-
withNugget
Surround the given code with a Performance Nugget- Parameters:
name
- the nugget namer
- the stuff to run
-
withNugget
Surround the given code with a Performance Nugget- Parameters:
name
- the nugget namer
- the stuff to run- Returns:
- the result of the stuff to run
-
withNuggetThrowing
public static <T extends Exception> void withNuggetThrowing(String name, long inputSize, com.fishlib.base.Procedure.ThrowingNullary<T> r) throws T Surround the given code with a Performance Nugget- Parameters:
r
- the stuff to run- Throws:
T
- exception of type T
-
withNuggetThrowing
public static <R,ExceptionType extends Exception> R withNuggetThrowing(String name, long inputSize, com.fishlib.base.Function.ThrowingNullary<R, ExceptionType> r) throws ExceptionTypeSurround the given code with a Performance Nugget- Parameters:
name
- the nugget namer
- the stuff to run- Returns:
- the result of the stuff to run
- Throws:
ExceptionType
- exception of type ExceptionType
-
setCallsite
Attempt to set the thread local callsite so that invocations of
getCallerLine()
will not spend time trying to recompute.This method returns a boolean if the value was successfully set. In the event this returns true, it's the responsibility of the caller to invoke
clearCallsite()
when the operation is complete.It is good practice to do this with try{} finally{} block
final boolean shouldClear = QueryPerformanceRecorder.setCallsite("CALLSITE"); try { // Do work } finally { if(shouldClear) { QueryPerformanceRecorder.clearCallsite(); } }
- Parameters:
callsite
- The call site to use.- Returns:
- true if successfully set, false otherwise/
-
setCallsite
public static boolean setCallsite()Attempt to compute and set the thread local callsite so that invocations of
getCallerLine()
will not spend time trying to recompute.Users should follow the best practice as described by
setCallsite(String)
- Returns:
- true if the callsite was computed and set.
-
clearCallsite
public static void clearCallsite()Clear any previously set callsite. SeesetCallsite(String)
-