Contextual and GC friendly user timing
Nobody has claimed this yet.
- Dominant language
- Bikeshed
- Stars
- 31
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Description
As the status quo, the user marks and measures are globally buffered and need to be cleared manually with performance.clearMarks and performance.clearMeasures. In wild practice, this can be very awkward for applications or libraries that record repetitive series of operations: their marks and measures have to be prefixed to prevent from colliding from maybe overlapping async operations, and they must clear the marks and measures with prefixed names with performance.clearMarks and performance.clearMeasures after the operations complete.
If the marks and measures are not cleared correctly, they are likely to get memory leakages. This is not a very idiom JavaScript resource management pattern. It can be better if those buffered entries can be garbage collected once their contextual async operation is not referenced anymore.
This problem stands out on Node.js significantly. Node.js provides standard-compliant user timing API to allow applications or libraries to work with Web platforms seamlessly, whilst those applications or libraries are supposed to run code repetitively on the server-side.
If the user timing can be created under a contextual performance timeline, then this specific performance timeline can be referenced from the context of these async operations, like events, requests, etc. Once the context of these operations was not used anymore, all of them can be garbage collected cleanly. And there won't need the name prefixes for entries since they are not put into the global performance timeline and won't get overlapping with each other.
Conceptual usage:
addEventListener('an_event_name', event => {
const eventPerformance = new Performance('click event');
eventPerformance.mark('mark a');
asyncOperation()
.then(() => {
eventPerformance.measure('measure a', 'mark a');
logEntries(eventPerformance.getEntries());
// eventPerformance and their user timing can be GC-ed without manual clearance.
});
});
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue contains a conceptual usage example but names no repository files, tests, or implementation entry points. Start by reading the User Timing specification and related performance-timeline behavior; the scope is complete only when a decided design and corresponding specification changes define contextual timelines and garbage-collection behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100