typelevel / typelevel/cats-effect

Use libunwind for tracing on Native

Open
#3,297 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

:microscope: experiment :mushroom: enhancement
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 added tracing for Native based on the tried-and-true JVM/JS strategy of creating a Throwable and using its stack trace to introspect the call stack.

However, in Native we can explore using libunwind to directly introspect the stack without creating an exception. Furthermore, we could unwind only as far as we need (probably only 1 or 2 frames, to find the caller) instead of the entire stack. That might even mean that we don't need all the filtering jazz.

https://github.com/scala-native/scala-native/blob/093a89ae2a07a7e77b837e78b66317ed8d6bd411/nativelib/src/main/scala/scala/scalanative/runtime/unwind.scala

Ideally this should improve cold start performance (when traces are first generated and cached) or anyone using full tracing. It could also improve the performance of enhancing exceptions, if filtering stack traces was no longer necessary.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Scala Native unwind.scala implementation linked in the issue, then compare it with the Native tracing added in pull request 3195. Determine whether libunwind can replace Throwable-based stack inspection and limit unwinding to the needed frames; done means tracing and exception enhancement work with the intended performance improvement.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
observability, performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.