Hello! I am using Ktor for some time now and I cou...
# ktor
f
Hello! I am using Ktor for some time now and I could say that I became pretty familiar, but there is still a thing that puzzles me 😅 What problem addresses / solves
SuspendFunctionGun
in respect to the naive implementation of
DebugPipelineExecutor
? @e5l maybe you can help me understand, as you are one of the main committers, Thank you!
e
Hey @Florentin Simion, the only purpose of
SuspendFunctionGun
is reduce amount of allocations during Pipeline execution.
DebugPipelineExecutor
preserves stacks of all interceptors so it's possible to observe full coroutine stack frames with all plugins during the debug process
f
Thank you for the quick response. So, just to be sure I got it,
SuspendFunctionGun
only keeps the stack trace of the current running interceptor?
I am asking this, because what you said, made sense for me too, in the old implementation when you were starting a new coroutine for every interceptor which didn't aggregate stack traces. But now, I saw that the implementation was changed. which no longer does that. So, I was thinking if they are running in the same coroutine, aren't now the stack traces aggregated?
e
It depends on suspension points you have actually
f
I think I may got it this time 😄 This is due to the
Continuation
implementation in SuspendFunctionGun, which has
override fun getStackTraceElement(): StackTraceElement? = null
and this is how you keep the stack trace only for the current interceptor? And the coroutine start in the old implementation had nothing to do with it, it was just an implementation detail.
1
Awesome, thanks a lot!
e
Yep, and the continuation is reused
👍 2