-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
show-size.py
executable file
·46 lines (37 loc) · 1.62 KB
/
show-size.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python3
import requests
def stat(cf, prop):
res = requests.get(f"http://localhost:9002/monitor/cf/{cf}/rocksdb.{prop}")
res.raise_for_status()
return res.json()
def bytes(num):
for unit in ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"]:
if abs(num) < 1024:
return "%3.1f %s" % (num, unit)
num /= 1024
def num(num):
for unit in ["", " thousand", " million", " billion", " trillion"]:
if abs(num) < 1000:
return "%3.1f%s" % (num, unit)
num /= 1000
num_lichess_games = stat("lichess_game", "estimate-num-keys")
size_lichess_games = stat("lichess_game", "live-sst-files-size")
num_lichess = stat("lichess", "estimate-num-keys")
size_lichess = stat("lichess", "live-sst-files-size")
size = size_lichess + size_lichess_games
target = 3_910_674_537
print(f"Games: {num(num_lichess_games)}")
print(f"Size: {bytes(size_lichess_games)}")
print(f"Per game: {bytes(size_lichess_games / num_lichess_games)}")
print("---")
print(f"Positions: {num(num_lichess)}")
print(f"Size: {bytes(size_lichess)}")
print(f"Per game: {bytes(size_lichess / num_lichess_games)}")
print("---")
print(f"Total size: {bytes(size)}")
print(f"Total size per game: {bytes(size / num_lichess_games)}")
print(f"Total size per position: {bytes(size / num_lichess)} = 12 B + 2 B + {bytes(size / num_lichess - 12 - 2)}")
print("---")
print(f"Progress: {num_lichess_games / target * 100:0.1f}%")
print(f"Projected positions at {num(target)} games: {num(num_lichess / num_lichess_games * target)}")
print(f"Projected size at {num(target)} games: {bytes(size / num_lichess_games * target)}")