Gitea web is slow to open large repo

This is easy to reproduce. Find a large repository with lots of history and committers. Mirror it to a local Gitea instance. I will use https://git.FreeBSD.org/ports.git since that’s how I was able to produce this behavior.

Depending on how fast/slow your server is you may or may not be able to use the migration tool in the web UI. For me it was timing out. My server is a dual socket Xeon 3.00GHz with 16 GB of RAM on NVMe’s.

I had to do it manually after creating an empty repository with the web UI.

git clone https://git.FreeBSD.org/ports.git
cd ports
git remote add gitea git@git.domain.tld:freebsd/ports.git
git push -u gitea main:master

Now try to browse to the repository on your local Gitea instance, ie. https://git.domain.tld/freebsd/ports.git

Note: if you are using an Apache HTTP server as a remote proxy to Gitea you may need to increase the time out with ProxyTimeout. I set mine to 180 seconds.

Look at the process list on your server. You’ll see 100% CPU usage for gitea web while the page continues to load in your browser. Eventually (if the reverse proxy doesn’t timeout) the page is displayed. This is understandable. It’s the first time the large repository is opened in Gitea.

Now refresh the page. It unfortunately takes the same amount of time to load. I would have hoped that some caching would be in use to speed that up.

My Gitea’s app.ini can be seen here.

If I browse in an large project on my local Gitea 1.14.1 instance than it need for the first calls ~6-7 seconds. Than the data will be cached in Memcached and the seconds calls are fast.

My Gitea is running on Intel NUC with an Celeron j5005 CPU, 8GB RAM and SATAIII SSD.

I wonder what else I can do besides increasing the time out. It seems that setting something as high as 720 seconds is still not enough.

Apache Log

[Thu Apr 22 02:16:10.504363 2021] [proxy_http:error] [pid 89063] (70007)The timeout specified has expired: [client X.X.X.X:34526] AH01102: error reading status line from remote server git.domain.tld:3000
[Thu Apr 22 02:16:10.504531 2021] [proxy:error] [pid 89063] [client x.x.x.x:34526] AH00898: Error reading from remote server returned by /freebsd/ports/git-upload-pack

The process list shows this:

git      15544   0.0 10.9 3541608 1816600  -  S    14Mar21    910:39.28 | `-- /usr/local/sbin/gitea web
git      75555   0.0  0.0  160520    7508  -  S    02:04        0:00.39 |   `-- /usr/local/bin/git upload-pack --stateless-rpc /var/db/gitea/gitea-repositories/freebsd/ports.git
git      75556 100.0  7.1 1462324 1183576  -  R    02:04       12:41.67 |     `-- /usr/local/libexec/git-core/git --shallow-file pack-objects --revs --thin --stdout --shallow --progress --delta-base-offset --include-tag

This is when doing a git pull

You can open an performance issue on GitHub.