go-chi / chi

lightweight, idiomatic and composable router for building Go HTTP services
https://go-chi.io
MIT License
18.26k stars 980 forks source link

High CPU usage by chi.setPathValue #916

Closed aadi-1024 closed 1 week ago

aadi-1024 commented 4 months ago

Hello

I'm not sure if this is an issue with Chi or somewhere in my own application, but the setPathValue() function seems to be causing very high CPU usage for me. It seems to be due to the hashing taking place in the function(pardon if I'm wrong) as I could infer from the pprof profile output.

image

The generated chart:

image

Any help appreciated!

aadi-1024 commented 4 months ago

image

could this be the issue? all the entries are just "*"

aadi-1024 commented 4 months ago

A bit more digging around and it seems mounting a group with a prefix "/" causes this. I'll look into a bit more to see if I can fix this

VojtechVitek commented 1 week ago

Any other volunteers to look into this? Or should we close?

aadi-1024 commented 1 week ago

I'll be looking into this again once I can manage some time :). Till then I suppose we can close this, I'll open a new issue if I'm able to solve it. Or maybe can just wait for other volunteers to chime in.