Description
Context
Currently the scope of skel is best practices through working examples.
However in #29 we are experimenting with writing sample code that exhibits "common performance problems" like thread contention along with code that demonstrates idealized cpu usage for async code. The motivation is that:
- the scenarios (good perf and bad) have more value and are easier to explain in direction comparison
- a problem like
thread contention
is quietly sinister: you can't see it, there is no obvious crash or error. Just a slow program.
So, we plan to document the tell-tale signs of things like thread contention
when seen via a profiler.
Demonstrating diagnostics to catch hard to see bugs
Similar to thread contention
that may be difficult to diagnose without specialized methods like function level profiling, there is a class of dangerous bugs that can cause silent memory corruption and are not often detectable without advanced methods.
Therefore, we could consider adding example code (perhaps first in an advanced branch) that contains intentional dangerous bugs that corrupt memory. Then write documentation for how to detect them.
Examples/ideas:
- Attempt to convert empty v8 objects
- Interacting with V8 objects in invalid ways can silently succeed in release (probably corrupting memory) but will crash in DEBUG mode.
- Write docs about how to install
node_g
(debug node build) and leverage the advanced checks in V8 that catch programming errors and abort: https://github.com/nodejs/node/blob/73ae2d1895c2c0d1d4eeaddd284c58d776d2be87/deps/v8/src/base/logging.h - Refs Protect from invalid args passed to coalesce carmen-cache#85 for an example of this bug
- Intentionally corrupt the v8 heap
- Write docs that describe how to use the
node --verify-heap
flag to catch the problem. This could be tricky, but we can learn from how the v8 engineers try to do this: https://bugs.chromium.org/p/v8/issues/detail?id=2120
- Write docs that describe how to use the