Flush pending background work
Flushing forces pending background work to complete in parallel with your main thread, rather than waiting for it after your code finishes. When you run evaluations with large datasets, you may experience a long delay before program execution completes, while the dataset uploads in background threads. This occurs when main thread execution finishes before background clean-up completes. Callingclient.flush() forces all background tasks to process in the main thread, ensuring parallel processing during main thread execution. This can improve performance when user code completes before data uploads to the server.
The following example flushes pending background work after an evaluation:
Increase client parallelism
Increasing client parallelism gives Weave more threads to use for background work such as dataset uploads, which can further reduce clean-up time alongside flushing. Weave determines client parallelism automatically based on the environment, but you can set it manually using the following environment variable:WEAVE_CLIENT_PARALLELISM: The number of threads available for parallel processing. Increasing this value can improve the performance of background tasks such as dataset uploads.
settings argument to weave.init():
Performance Evaluation