sqlite and misc optimizations:

* exponentially slow upload handshakes caused by lack of rd+fn
   sqlite index; became apparent after a volume hit 200k files
* listing big folders 5% faster due to `_quotep3b`
* optimize `unquote`, 20% faster but only used rarely
* reindex on startup 150x faster in some rare cases
   (same filename in MANY folders)

the database is now around 10% larger (likely worst-case)
This commit is contained in:
ed 2024-09-15 13:18:43 +00:00
parent 2927bbb2d6
commit d67e9cc507
5 changed files with 146 additions and 43 deletions

View file

@ -3,6 +3,7 @@
from __future__ import print_function, unicode_literals
import os
import random
import re
import shutil
import socket
@ -49,6 +50,10 @@ from copyparty.util import FHC, CachedDict, Garda, Unrecv
init_E(E)
def randbytes(n):
return random.getrandbits(n * 8).to_bytes(n, "little")
def runcmd(argv):
p = sp.Popen(argv, stdout=sp.PIPE, stderr=sp.PIPE)
stdout, stderr = p.communicate()