Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cu): defer prep work for eval until right before work is being sent to worker #937

Merged
merged 3 commits into from
Aug 4, 2024

Conversation

TillaTheHun0
Copy link
Member

@TillaTheHun0 TillaTheHun0 commented Aug 2, 2024

/**
   * Some of the work performed, in prep for sending the task to the worker thread pool,
   * ie. copying the process memory so that each eval stream may have their own memory
   * to pass back and forth (see below), can be resource intensive.
   *
   * If the thread pool is fully utilized, the pool will start to queue tasks sent to it on the main-thread.
   * Subsequently, the amount of time between when the "prep-work" and
   * the "actual evaluation work" are performed can grow very large.
   *
   * This effectively produces a "front-loading" effect, where all the "prep-work" is ran
   * all up front, then queued for a worker to eventually take on the actual work.
   *
   * In other words, resource intensive data strucutres ie. process memory can just be
   * sitting queued for long periods of time, waiting for an available worker thread. We need to mitigate this.
   *
   * So for each worker thread pool, we utilize a queue with matching concurrency as the thread pool,
   * which will defer performing the "prep-work" until right before a worker is available to perform the "actual work",
   * ergo eliminating the "front-loading" effect.
   *
   * (see pQueue instantitations below)
   */

Subsequently, since we are queueing on the main thread, instead of letting the thread pool manage the queueing, the number of pendingTasks as reported by the thread pool will always be 0. So we instead use the size of the queue on the main thread when reporting and logging metrics.

Also bumps dependencies, some housekeeping.

@TillaTheHun0 TillaTheHun0 merged commit b0f543f into main Aug 4, 2024
3 checks passed
@TillaTheHun0 TillaTheHun0 deleted the tillathehun0/cu-queue-mem-copy branch August 4, 2024 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant