-
Notifications
You must be signed in to change notification settings - Fork 14
docs(utils): clarify buffered mode implementation in PerformanceObserverSink #1233
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
docs(utils): clarify buffered mode implementation in PerformanceObserverSink #1233
Conversation
…d limitations Co-authored-by: BioPhoton <10064416+BioPhoton@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
| * ## Buffered Mode Implementation | ||
| * | ||
| * When `captureBufferedEntries` is true, this method captures all performance entries | ||
| * that exist in the Node.js performance buffer at the time of subscription. | ||
| * | ||
| * **Why Manual Approach:** | ||
| * The standard `buffered: true` option in PerformanceObserver.observe() is not used | ||
| * because it has proven unreliable in Node.js environments. Instead, we use | ||
| * `performance.getEntriesByType()` to manually retrieve buffered entries. | ||
| * | ||
| * **Guarantees:** | ||
| * - All marks and measures in the performance buffer at subscription time will be captured | ||
| * - Entries are processed synchronously before the observer begins watching for new entries | ||
| * - No entries created after subscription will be missed (observer handles them) | ||
| * | ||
| * **Limitations:** | ||
| * - Potential for duplicate processing if an entry exists both in the buffer and is | ||
| * delivered by the observer callback (though Node.js typically avoids this) | ||
| * - Performance buffer has a limited size; very old entries may have been evicted by Node.js | ||
| * - The manual approach captures a snapshot at subscription time; there's a small race | ||
| * condition window where entries created during getEntriesByType() execution might | ||
| * be captured by both the manual call and the observer | ||
| * | ||
| * **Memory Management:** | ||
| * Applications should call `performance.clearMarks()` and `performance.clearMeasures()` | ||
| * periodically to prevent the Node.js performance buffer from growing unbounded. | ||
| * This is especially important when using buffered mode, as the entire buffer is | ||
| * processed on subscription. | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too muh test. could you reduce it to 1 sentence @copilot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reduced the extensive documentation section to one concise sentence that explains the manual approach and why the native option isn't used. Changes in commit 37cc84e.
Co-authored-by: BioPhoton <10064416+BioPhoton@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
The
subscribe()method uses a manualperformance.getEntriesByType()workaround instead of the nativebufferedoption, but documentation was unclear about why.Changes
captureBufferedEntriesoption: Simplified documentation to explain the manual approach usingperformance.getEntriesByType()and note that the nativebufferedoption is unreliable in Node.jssubscribe()method: Added concise explanation that buffered entries are captured viaperformance.getEntriesByType()instead of the unreliable nativebufferedoptionThe documentation now concisely explains why the manual approach is used (native
bufferedoption unreliability) without extensive detail about guarantees, limitations, or memory management.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.