uber/RxDogTag

Alternative solutions

Opened this issue · 1 comments

Right now, RxDogTag is implemented via throwing an exception and capturing the stack frame at that point. While we haven't seen any measurable performance impact at a macro level, it's certainly not free either. This issue exists to capture possible alternative implementation ideas.

Bytecode transformer

Recognizes certain subscribe() signatures and re-weaves them to have the hardcoded subscribe tag present with a custom tagging observer. Cost is just a string then.

  • Pros:
    • Effectively zero runtime overhead
  • Cons:
    • Invasive
    • Potentially mangles stacktraces
    • Could impact build times
    • Unclear what API could/would be used, or if line/method/class information is available.

Compiler plugin

Recognizes certain subscribe() signatures and re-weaves them to have the hardcoded subscribe tag present with a custom tagging observer. Cost is just a string then.

  • Pros:
    • Effectively zero runtime overhead
    • Should be low-to-no overhead with build times. Cacheable as part of compilation
  • Cons:
    • Invasive
    • Potentially mangles stacktraces
    • Language-dependent
    • No formally public APIs for Java or Kotlin, just non-public ones
    • Unclear what API could/would be used, or if line/method/class

A kotlin compiler plugin could be more feasible with Kotlin IR. We would effectively want to replace error-less subscribe points with the a tagged lambda observer