mirror of
https://github.com/vacp2p/research.git
synced 2025-02-24 04:08:15 +00:00
factor out load color prefix fmt
This commit is contained in:
parent
8e7fc41f21
commit
519fb3d334
@ -21,6 +21,22 @@ def magnitude_fmt(num):
|
||||
return "%2d%s" % (num, x)
|
||||
num /= 1000
|
||||
|
||||
# Color format based on daily bandwidth usage
|
||||
# <10mb/d = good, <30mb/d ok, <100mb/d bad, 100mb/d+ fail.
|
||||
def load_color_prefix(load):
|
||||
if load < (1024 * 1000 * 10):
|
||||
color_level = bcolors.OKBLUE
|
||||
elif load < (1024 * 1000 * 30):
|
||||
color_level = bcolors.OKGREEN
|
||||
elif load < (1024 * 1000 * 100):
|
||||
color_level = bcolors.WARNING
|
||||
else:
|
||||
color_level = bcolors.FAIL
|
||||
return color_level
|
||||
|
||||
def load_color_fmt(load, string):
|
||||
return load_color_prefix(load) + string + bcolors.ENDC
|
||||
|
||||
# We assume an envelope is 1kb
|
||||
envelope_size = 1024
|
||||
|
||||
@ -35,46 +51,20 @@ envelopes_per_message = 10
|
||||
# TODO: Split up by channel, etc
|
||||
received_messages_per_day = 100
|
||||
|
||||
# This means means 10*100*1= 1 MB per day
|
||||
|
||||
# oh, it is envelopes per time
|
||||
|
||||
# everyone received all messages
|
||||
|
||||
def bandwidth_usage(n_users):
|
||||
print(n_users)
|
||||
|
||||
#print(n_users * envelopes_per_message * received_messages_per_day)
|
||||
|
||||
# How much bandwidth does a receiving node waste?
|
||||
|
||||
# We assume a node is not relaying messages, but only sending
|
||||
|
||||
# Goal:
|
||||
# - make it user-bound, not network-bound
|
||||
# - reasonable bw and fetch time
|
||||
|
||||
# TODO: Offline take into account
|
||||
|
||||
# ~1GB per month, ~ 30 mb per day, ~1 mb per hour
|
||||
|
||||
# Offline proportion
|
||||
|
||||
|
||||
def case1():
|
||||
# Case 1: only receiving messages meant for you
|
||||
load = envelope_size * envelopes_per_message * \
|
||||
received_messages_per_day
|
||||
|
||||
if load < (1024 * 1000 * 10):
|
||||
color_level = bcolors.OKBLUE
|
||||
elif load < 30000:
|
||||
color_level = bcolors.OKGREEN
|
||||
elif load < 100000:
|
||||
color_level = bcolors.WARNING
|
||||
else:
|
||||
color_level = bcolors.FAIL
|
||||
|
||||
print bcolors.HEADER + "\nCase 1. Only receiving messages meant for you" + bcolors.ENDC
|
||||
print ""
|
||||
print "Assumptions:"
|
||||
@ -83,7 +73,7 @@ def case1():
|
||||
print "- A3. Received messages / day (static): " + str(received_messages_per_day)
|
||||
print "- A4. Only receiving messages meant for you"
|
||||
print ""
|
||||
print color_level + "For N users, receiving bandwidth is " + sizeof_fmt(load) + "/day" + bcolors.ENDC
|
||||
print load_color_fmt(load, "For N users, receiving bandwidth is " + sizeof_fmt(load) + "/day")
|
||||
print ""
|
||||
print("------------------------------------------------------------")
|
||||
|
||||
@ -94,20 +84,9 @@ def case2():
|
||||
return envelope_size * envelopes_per_message * \
|
||||
received_messages_per_day * n_users
|
||||
|
||||
def color(n_users):
|
||||
load = load_users(n_users)
|
||||
if load < 10000:
|
||||
color_level = bcolors.OKBLUE
|
||||
elif load < 30000:
|
||||
color_level = bcolors.OKGREEN
|
||||
elif load < 100000:
|
||||
color_level = bcolors.WARNING
|
||||
else:
|
||||
color_level = bcolors.FAIL
|
||||
return color_level
|
||||
|
||||
def usage_str(n_users):
|
||||
return color(n_users) + "For " + magnitude_fmt(n_users) + " users, receiving bandwidth is " + sizeof_fmt(load_users(n_users)) + "/day" + bcolors.ENDC
|
||||
load = load_users(n_users)
|
||||
return load_color_fmt(load, "For " + magnitude_fmt(n_users) + " users, receiving bandwidth is " + sizeof_fmt(load_users(n_users)) + "/day")
|
||||
|
||||
print bcolors.HEADER + "\nCase 2. Receiving messages for everyone" + bcolors.ENDC
|
||||
print ""
|
||||
@ -124,9 +103,25 @@ def case2():
|
||||
print("------------------------------------------------------------")
|
||||
|
||||
|
||||
|
||||
# Assume half of all messages are in 1:1 and group chat
|
||||
# XXX: Implicitly assume message/envelope ratio same for 1:1 and public,
|
||||
# probably not true due to things like key negotiation and data sync
|
||||
private_message_proportion = 0.5
|
||||
|
||||
# Case 3: all private messages go over one discovery topic
|
||||
|
||||
case1()
|
||||
case2()
|
||||
#case3()
|
||||
|
||||
|
||||
# Ok, let's get serious. What assumptions do we need to encode?
|
||||
# Also, what did I observe? I observed 15GB/m = 500mb per day.
|
||||
|
||||
# Things to encode:
|
||||
# - Noisy topic
|
||||
# - Duplicate messages
|
||||
# - Bloom filter false positives
|
||||
# - Bugs / invalid messages
|
||||
# - Offline case dominant
|
||||
|
Loading…
x
Reference in New Issue
Block a user