When p2phttp is serving many repositories, it currently needs to run several git processes in each at startup. This can make startup take a long time before it is listening to or responding to http requests.
It should be possible for p2phttp to start up quickly, without creating an Annex state for each repository. And demand load it when a repositry is accessed. (Or load them in the background as an idle time job.)
This would need a uuid -> repository map.
That could be a sqlite database that contains eg:
UUID,InodeCache,OsPath
Where the InodeCache is of the git config file that was read to learn the UUID. That way, in the unlikely event that a repository UUID changes, the new UUID is learned on startup. (It is not safe to change UUID while git-annex is running of course.)
Another benefit of such a map is that, when a request comes in for an
unknown UUID, p2phttp --directory currently re-scans all repositories,
making Annex states for all of them. That blocks all other (new) requests
until complete. It should be possible to avoid any blocking of requests
for existing repos during that scan, and I think that should be done
to avoid any chance of DOS attack. But also using the map will speed up
the scan, and deman loading of Annex states will too. --Joey
Demand loading Annex state would also allow freeing Annex state when a repository has not been accessed in a long time. As p2phttp scales to large numbers of repositories, the memory used for Annex states for each repository (times the number of jobs) might eventually become a scalability problem, so it would be good to have an architecture that allows freeing unused states.
And git-annex got a shiny new LRU cache implementation recently, that could be used for this.