Thoughts on measuring snaps resource consumption (to be refined in a conversation)
- Dominant language
- TypeScript
- Stars
- 853
- Forks
- 662
- Avg merge
- 2d 8h
- Merged PRs (30d)
- 8
Description
1. eventloop montoring
A mechanism known from https://www.npmjs.com/package/blocked
TL;DR: setInterval checking what's the difference between the timestamps of its invocation and if it is significantly higher than the declared time for the setInterval.
Large difference means event loop was blocked with a long chunk of synchronous work and couldn't run the function scheduled in interval.
1.1. Could implement the same interval mechanism inside the iframe (in snap initialization) and ping parent window regularly while everything is fine. Bad results (TBD define bad) get the snap killed
1.2. Could give the snap an API to call and therefore implement a kind of "dead man switch"
2. memory
Assuming event loop is not blocked, we can use the browser's performance interface to track memory usage in the window context for the snap and report that to the code that controls if snap stays alive
Contributor guide
Research direction
No source files or tests are named. Start by tracing snap initialization and the code that controls snap lifetime, then evaluate the proposed iframe event-loop interval and browser performance memory reporting. Done requires agreed resource thresholds, reporting behavior, and a defined response when a snap exceeds them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100