typelevel / typelevel/cats-effect
Make it possible to configure tracing in release mode on Native
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 2.2k
- Forks
- 576
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 18
Description
In https://github.com/typelevel/cats-effect/pull/3195 I only made it possible to use tracing on Native in debug mode, like JS. In release mode the tracing-related code is completely elided—there is no way to enable it. But apparently some people still get exceptions in production 🙄
On the JVM we can load a boolean into a static final field at runtime and rely the JIT to elide tracing-related branches if it is disabled. This is not an option for ahead-of-time compilation on Native. However, perhaps there is a way that tracing can be configured by the user at linking time.
For example: we could include some C code in Cats Effect:
// off = 0, cached = 1, full = 2
int cats_effect_tracing_mode() {
#ifdef CATS_EFFECT_TRACING_MODE
return CATS_EFFECT_TRACING_MODE;
#else
return 1;
#endif
}
Users could then configure this by adding e.g. -DCATS_EFFECT_TRACING_MODE=0 to nativeCompileOptions in their applications. Additionally, they would have to enable LTO (link-time-optimization). Then, in theory, it should be possible for tracing-related code to be eliminated, but this would have to be investigated, since it would be happening in the LLVM pipeline.
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
Review PR 3195 and the Native release-mode tracing path, then investigate how nativeCompileOptions, LTO, and the LLVM pipeline interact with a C linker-time setting. Done means users can configure tracing in Native release builds and verify that tracing code is elided when disabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, scala
- Domain
- build-system, compilers, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100