https://kotlinlang.org logo
#ktor
Title
# ktor
f

Florentin Simion

01/12/2022, 2:15 PM
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

e5l

01/12/2022, 2:17 PM
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

Florentin Simion

01/12/2022, 2:25 PM
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

e5l

01/12/2022, 2:31 PM
It depends on suspension points you have actually
f

Florentin Simion

01/12/2022, 2:53 PM
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

e5l

01/12/2022, 2:54 PM
Yep, and the continuation is reused
👍 2
2 Views