Repository navigation
Slow startup caused by watch exclusion when --reload-excludes flag points to a very large folder
#2389
Replies: 1 comment
|
I think I found the cause of this. In for j in range(len(directories)):
for k in range(j + 1, len(directories)):
if directories[j] in directories[k].parents: ...That's O(N²) With uvicorn's own function on a venv-like tree (same results before/after):
Sorting by depth and checking each directory's parents against a set of already-kept directories gives the same result in one pass. I'll open a PR with this and a test. |
Uh oh!
There was an error while loading. Please reload this page.
Hello, I'm here to report an issue I encountered with a framework (
litestar) which makes use of uvicorn. You can follow the full discussion here. I will just give a tl;dr; belowDescription
When starting the development uvicorn server, the initial startup time takes about 2 minutes. I initially thought this was due to running the project via WSL, and therefore the filesystem virtualization may be the root cause, but I was wrong.
Setup
After much testing, it was discovered that the issue was more isolated, and was related to how uvicorn handles excluded files (
--reload-excludeflag). In this case, it was instructed to exclude all files inside a virtual environment folder created by poetry.Problem analysis
It seems to me that when uvicorn is instructed to reload on change, and a list of excluded files are passed to it, it starts doing some computationally intensive work during those moments, which causes all other operations to hang. I say this because I ran the program through
straceand for the last 70-90% of those 2 minutes, no system calls are being made and nothing is printing to the console, which means it's either doing nothing or trying to do "everything". I didn't check system resources to know what the case might be, but I'm willing to bet it was simply crunching away on some algorithm.Anyways, that's all I have for that. I'll do my best to respond to clarifications. Have a nice day 👋🏼
All reactions