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

Throttling of deno execution #629

Open
deeprobin opened this issue Mar 2, 2024 · 4 comments
Open

Throttling of deno execution #629

deeprobin opened this issue Mar 2, 2024 · 4 comments

Comments

@deeprobin
Copy link

Hey,

in my rust infra I currently schedule some Deno-"tasks".
Is there a way to manually throttle the Deno execution without using OS APIs?

@bartlomieju
Copy link
Member

Can you provide some more details into what kind of throttling are you looking for?

@deeprobin
Copy link
Author

@bartlomieju

Can you provide some more details into what kind of throttling are you looking for?

Basically, the point is that I have an agent-like structure in certain use cases.

I then start a .js/.ts entrypoint using deno_core.

To better distribute the load or prioritise other tasks, I would like to manually throttle the execution of the JavaScript/TypeScript code and let the CPU focus more on something else.

In my opinion, it is easier to limit the memory usage. But CPU utilisation is the crux of the matter.

Do you have any ideas?

@rracariu
Copy link

rracariu commented Mar 9, 2024

This might be related to denoland/deno#13654
TLDR:
v8 does not offer an API for setting CPU quotas per isolate. You might need to rely on system specific APIs to do this.

@bartlomieju
Copy link
Member

@deeprobin the solution for you is to use JsRuntime::poll_event_loop instead of JsRuntime::run_event_loop and schedule these polls when you have available CPU budget.

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

No branches or pull requests

3 participants