https://kotlinlang.org logo
#kobweb
Title
# kobweb
h

hamyn

09/24/2023, 10:58 PM
Is it normal for
kobweb run
to lock up a whole thread(100% util) ?
d

David Herman

09/24/2023, 11:45 PM
Try running
./gradlew kobwebStart -t
instead and compare, same result? It's probably expected, especially the first time you run it. Compiling is hard, use all the CPU you can!
h

hamyn

09/25/2023, 12:28 AM
Yup, Webpack of course uses a lot when recompiling but dev server is always utilizing 100% of some thread even on IDLE
i don't remember ktor being this cpu heavy, what am I missing ?
d

David Herman

09/25/2023, 12:47 AM
Ah, it's 100% utilized after everything started and the server is running? That's very strange
h

hamyn

09/25/2023, 1:02 AM
Yes
I've set the log level to ALL and used it a bit, now I'm analyzing the log file
d

David Herman

09/25/2023, 1:03 AM
Thanks
The server should be pretty quiet
It does read the state of a file every 300ms (and then sleeps)
That's the only thing I do custom besides just letting ktor do its own thing
h

hamyn

09/25/2023, 1:14 AM
I've got 150 hits on "FAILURE ..." and almost all of them are
"Selector didn't match" @/api
with same child element but it ends with
@ /{...}/
d

David Herman

09/25/2023, 1:15 AM
I can look into that, but 150 hits shouldn't cause 100% thread utiliziation
h

hamyn

09/25/2023, 1:16 AM
I'll try running it on a different project, let's see
d

David Herman

09/25/2023, 1:16 AM
Appreciate it
You can try with
kobweb create app
,
kobweb create examples/clock
, and/or
kobweb create examples/jb/counter
?
h

hamyn

09/25/2023, 1:30 AM
Okay will do
d

David Herman

09/25/2023, 1:31 AM
The last one (
examples/jb/counter
) is about as simple as a Kobweb project can get
h

hamyn

09/25/2023, 1:32 AM
trying with that one then
thank you color 1
Same, nothing weird in the log file
d

David Herman

09/25/2023, 1:43 AM
What's your OS?
h

hamyn

09/25/2023, 1:43 AM
Linux
d

David Herman

09/25/2023, 1:43 AM
I'll see if I can repro
Does
./gradlew kobwebStart -t
also throttle your thread?
h

hamyn

09/25/2023, 1:46 AM
yes
Might it be jdk related ? I'm using 11-*-jbr
d

David Herman

09/25/2023, 1:47 AM
So maybe I should check my assumption. You're saying I'm locking a thread, but not necessarily locking up a CPU?
My code does work by running in an infinite while loop that sleeps... and then when it gets a signal that the server can shut down, it exits the loop, shuts down ktor, and exits main
h

hamyn

09/25/2023, 1:50 AM
No not the whole CPU but always one of the threads when idling is at 100%, it changes to a different thread from time to time(~4,5 seconds)
h

hamyn

09/25/2023, 1:51 AM
Thread changing is probably by the OS scheduler but idk
d

David Herman

09/25/2023, 1:52 AM
Maybe the way I wrote that code is not thread friendly
So yes, I'm seeing a thread pegged at 100%. It says the command associated with the thread is
logback-1
h

hamyn

09/25/2023, 1:55 AM
yup
I was just going to mention that
d

David Herman

09/25/2023, 1:57 AM
I do configure logging a bit. Let me see if that's related.
thank you color 1
Although it is dinnertime here, so it will be an hour or two
h

hamyn

09/25/2023, 1:58 AM
No problem, thanks for helping out
d

David Herman

09/25/2023, 1:58 AM
Sure. I was totally unaware so thanks for reporting.
h

hamyn

09/25/2023, 2:00 AM
Meanwhile I will look into it too, maybe this yet-to-be-a-junior will spot something )
d

David Herman

09/25/2023, 3:31 AM
Sure, no pressure! The things I'm asking myself are... 1. Is this ktor? Can I repro it in normal ktor projects? Or is it something in my code? 2. Is this related to my specific version of ktor? Does upgrading fix it? 3. (After seeing the
logback
thread name) Is this related to how I'm configuring logback? 4. How bad is this really? Is this actually resulting in significant performance degradation that people would notice without using profiling tools?
h

hamyn

09/25/2023, 3:31 AM
Can I dm you ?
It's probably not ktor related
d

David Herman

09/25/2023, 3:32 AM
If you want to play with code itself, you can sync kobweb
git clone <https://github.com/varabyte/kobweb>
, go into
playground/site
, and run
kobweb run
in there. That way, you can actually change code under
backend/server/
, quit, and rerun, to see if things are still happening.
Can I dm you ?
Absolutely!
h

hamyn

09/25/2023, 3:32 AM
I've already been debugging the server