diagnostics_channel: grow native channel storage#64497
Conversation
|
Review requested:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #64497 +/- ##
=======================================
Coverage 90.24% 90.24%
=======================================
Files 739 739
Lines 241669 241682 +13
Branches 45543 45554 +11
=======================================
+ Hits 218087 218113 +26
+ Misses 15150 15112 -38
- Partials 8432 8457 +25
🚀 New features to boost your workflow:
|
Every string-named JavaScript channel consumed an entry in the fixed native subscriber array. Creating more than 1,024 channels triggered a CHECK and terminated the process. Allocate slots only for native publishers and grow the aliased buffer when it fills. Refresh the JavaScript view after resizing and preserve the capacity in snapshots. Signed-off-by: Stephen Belanger <admin@stephenbelanger.com>
af80173 to
3a6cf52
Compare
| this.name = name; | ||
| if (typeof name === 'string') { | ||
| this._index = dc_binding.getOrCreateChannelIndex(name); | ||
| this._index = undefined; |
There was a problem hiding this comment.
Why is this only done in case typeof name === 'string'?
I think the if should be removed.
There was a problem hiding this comment.
Symbol channels aren't supported/used on the native side, so we skip them here.
There was a problem hiding this comment.
but if I get this right we either set explict undefined or implict by not setting it at all.
What is the difference to never add it or always set it to undefined?
| const { triggerUncaughtException } = internalBinding('errors'); | ||
|
|
||
| const dc_binding = internalBinding('diagnostics_channel'); | ||
| const { subscribers: subscriberCounts } = dc_binding; |
There was a problem hiding this comment.
If I understand this right the growing of subscribers disallows destruction here as we would end up in a dangling reference.
Do we have any tools in hand to detect such subtle import issues?
| const dc_binding = internalBinding('diagnostics_channel'); | ||
| dc_binding.linkNativeChannel((name) => dc.channel(name)); | ||
| dc_binding.linkNativeChannel((name, index) => { | ||
| const channel = dc.channel(name); |
There was a problem hiding this comment.
I guess there is no simple way to avoid code duplication with lib/diagnostics_channel.js right?
Every string-named diagnostics channel currently consumes an entry in a fixed
native subscriber array, so creating more than 1,024 channels terminates the
process at a native
CHECK.Only channels used by native publishers now receive native slots, and the
subscriber buffer grows when it fills. This removes the arbitrary crash while
preserving subscriber tracking and snapshot behavior.
cc @nodejs/diagnostics