denoland / deploy_feedback

For reporting issues with Deno Deploy
https://deno.com/deploy
74 stars 5 forks source link

Deno deploy API to check remaining CPU time #611

Open inverted-capital opened 7 months ago

inverted-capital commented 7 months ago

What problem are you trying to solve?

I use queues to break down my workload. Sometimes, I could do further processing depending on the size of the batch, but I am unsure if I am close to using my CPU allotment. I would like to be able to check, like Deno.cpuTimeRemaining() and make a decision on how to proceed.

Describe the solution you'd like

Some way to see how much CPU time is left for this particular run, or if I should exit and start a new job on the queue.

Describe alternatives you've considered

Manually timing every call I make to do my own calculation, which makes my code look like it has been infected with smallpox 🧫

Documentation, Adoption, Migration Strategy

I think it would be very simple to understand for users - you have x ms left of y ms total, do as you wish.

This could also be expanded out to memory visibility too. Deno deploy has these measurements already, so naively it seems useful to make them available to the users inside the deploy functions ?

Thank you for making Deno and Deno deploy - they are great products ❤️

inverted-capital commented 5 months ago

Need something like the nodejs function: process.cpuUsage

inverted-capital commented 4 months ago

Found the top command in deployctl which helped immensely: https://docs.deno.com/deploy/manual/deployctl#top