All Projects → naugtur → Blocked At

naugtur / Blocked At

Licence: mit
Detects node eventloop block and reports where it started

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Blocked At

Retrace
基于mapping.txt文件,根据原始class名或方法名获取混淆后的class名或方法名,根据混淆后的class名或方法名获取原始class名或方法名,堆栈还原等
Stars: ✭ 41 (-81.28%)
Mutual labels:  stacktrace
Errors
Drop-in replacement for the standard library errors package and github.com/pkg/errors
Stars: ✭ 88 (-59.82%)
Mutual labels:  stacktrace
Ololog
A better console.log for the log-driven debugging junkies
Stars: ✭ 141 (-35.62%)
Mutual labels:  stacktrace
Actor.js
Elixir-style actors in JavaScript
Stars: ✭ 48 (-78.08%)
Mutual labels:  event-loop
Uvw
Header-only, event based, tiny and easy to use libuv wrapper in modern C++ - now available as also shared/static library!
Stars: ✭ 1,222 (+457.99%)
Mutual labels:  event-loop
Pasta Sourcemaps
Pretty (and) Accurate Stack Trace Analysis is an extension to the JavaScript source map format that allows for accurate function name decoding.
Stars: ✭ 112 (-48.86%)
Mutual labels:  stacktrace
Event Loop
ReactPHP's core reactor event loop that libraries can use for evented I/O.
Stars: ✭ 945 (+331.51%)
Mutual labels:  event-loop
Event Loop
An event loop interface for interoperability in PHP.
Stars: ✭ 170 (-22.37%)
Mutual labels:  event-loop
Backtrace
Makes Python tracebacks human friendly
Stars: ✭ 80 (-63.47%)
Mutual labels:  stacktrace
Clarify
Remove nodecore related stack trace noise
Stars: ✭ 140 (-36.07%)
Mutual labels:  stacktrace
Panic Overlay
Displays JS errors in browsers. Shows sources. Use with any framework. 💥✨
Stars: ✭ 50 (-77.17%)
Mutual labels:  stacktrace
Envelop.c
🌊 Thread-less, event-loop based tiny http-server from scratch using epoll. Learning Purpose.
Stars: ✭ 75 (-65.75%)
Mutual labels:  event-loop
Debugengine
Delphi debug framework
Stars: ✭ 133 (-39.27%)
Mutual labels:  stacktrace
Uvloop
Ultra fast asyncio event loop.
Stars: ✭ 8,246 (+3665.3%)
Mutual labels:  event-loop
Io uring Echo Server
io_uring echo server
Stars: ✭ 155 (-29.22%)
Mutual labels:  event-loop
Gmq
基于事件机制的多模块框架,支持动态库,grpc,websocket,mqtt等多种与后端通信组合方式. 模块动态替换,部分加载或者升级.
Stars: ✭ 31 (-85.84%)
Mutual labels:  event-loop
Eve
An extensible event-driven application framework in haskell
Stars: ✭ 101 (-53.88%)
Mutual labels:  event-loop
Mojo
✨ Mojolicious - Perl real-time web framework
Stars: ✭ 2,298 (+949.32%)
Mutual labels:  event-loop
Vert.x
Vert.x is a tool-kit for building reactive applications on the JVM
Stars: ✭ 12,544 (+5627.85%)
Mutual labels:  event-loop
Kuma
A network library implemented in C++, supports TCP/UDP/HTTP/HTTP2/WebSocket/SSL on platform Linux/Windows/OSX/iOS/Android.
Stars: ✭ 133 (-39.27%)
Mutual labels:  event-loop

blocked-at Build Status

Detects slow synchronous execution and reports where it started.

Installation

Requires Node 8+

$ npm install blocked-at

Usage

blocked((time, stack) => {
  console.log(`Blocked for ${time}ms, operation started here:`, stack)
})

Description

The blocked() function reports every value over the configured threshold (defaults to 20ms). Usage is similar to blocked but the detection mechanism is different, to allow pointing to the slow function.

It uses Async Hooks to measure the time and generate the stack trace. Stack trace will point to the beginning of an asynchronously called function that contained the long operation.

Run tests (npm test) to see examples.

There's a performance cost to enabling Async Hooks. It's recommended to detect blocking exists with something without the performance overhead and use blocked-at in testing environment to pinpoint where the slowdown happens. Rule of thumb is you should not be running this in production unless desperate.

Params and return value

const blocked = require('blocked-at')
const { stop } = blocked(fn, options)
  • fn: The callback function to execute when a function called asynchronously ran more than threshold. Two arguments are passed: time it measured and an array of stack frames (callstack)
  • options: Optional.
option default description
trimFalsePositives falsy eliminate a class of false positives (experimental)
threshold 20 minimum miliseconds of blockage to report. supported for parity with blocked
resourcesCap undefined maximum amount of stack traces with resource details kept in memory. Resources are not saved by default. see the next section for details
debug falsy print debug data to console

Returns: An object with stop method. stop() will disable the async hooks set up by this library and callback will no longer be called.

Using the stack trace

The stack trace is pointing to a start of a function called asynchronously, so in most cases the first stack frame pointing to your code is where you need to start analyzing all synchronous operations to find the slow one.

In some cases your code is not directly called and tracking it down will still be difficult. See how the http test case produces a stack pointing to Server.connectionListener as the slow function, because everything inside of it is synchronously called. You can always wrap your handlers' code in setImmediate if you become desperate. Or use resources.

Using the resource details

If you can't narrow down a blocking call to a particular function, you can try to use resourcesCap option and inspect an associated resource:

blocked((time, stack, {type, resource}) => {
 console.log(`Blocked for ${time}ms, operation started here:`, stack)
 if (type === 'HTTPPARSER' && resource) {
   // resource structure in this example assumes Node 10.x
   console.log(`URL related to blocking operation: ${resource.resource.incoming.url}`)
 }
}, {resourcesCap: 100})

Note that resource structure is a subject to change and may vary between Node versions.

Warning: Exposing resource details has a significant memory overhead, to the point of crashing the entire application due to exceeding heap limit. This is why resourcesCap is a number - it specifies the maximum amount of resources with details kept in memory. If this number is exceeded at runtime, you'll still get the information about blocked event loop, but resource will be undefined. Adjust it according to your needs. You can start arbitrarily with a 100 and decrease it if it's consuming too much memory or increase it if you don't see the details when you need them.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].