run_experiments.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #!/usr/bin/python3
  2. '''
  3. NOTE: This script is tailored for sizzle!
  4. Hence it does server thread allocation assuming 2 40-core processors.
  5. Currently assumes 8 threads (C72-79) are set aside for client simulator
  6. Run generate manifest with the maximum number of servers you are going to use
  7. and generate the keys for this before running experiments
  8. (Run ./App/getpubkeys to generate keys for the servers)
  9. '''
  10. import subprocess
  11. import os
  12. import sys
  13. import math
  14. from gen_manifest import generate_manifest
  15. from gen_enclave_config import generate_config
  16. ###############################################################################
  17. # CONFIGS TO SET:
  18. MANIFEST_FILE = "App/manifest.yaml"
  19. #MANIFESTS_FOLDER = "Manifests/"
  20. LOG_FOLDER = "Experiments_Plot_170424_Final/"
  21. RESULT_FOLDER = "Experiment_results/"
  22. '''
  23. # N = number of clients
  24. N = [1<<16, 1<<17, 1<<18, 1<<19, 1<<20, 1<<21]
  25. # M = number of servers
  26. M = [1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 18, 20, 24, 26, 28, 32, 36, 40, 48, 56, 64, 72]
  27. # T = threads per server instance
  28. T = [2, 4, 8, 16]
  29. '''
  30. N = [1<<16, 1<<17, 1<<18, 1<<19, 1<<20]
  31. M = [72, 64, 48, 36, 24, 16, 8, 4, 2, 1]
  32. T = [16, 8, 4, 2, 1]
  33. # Max servers depending on number of threads
  34. M_MAX = {
  35. 1:72, # 24 in M
  36. 2:36, # 19 in M
  37. 4:18, # 13 in M
  38. 8:9, # 8 in M
  39. 16:4 # 4 in M
  40. }
  41. # B = msg_size (-u)
  42. B = 256
  43. ###############################################################################
  44. def epoch_time(n, m, t, b):
  45. # Base epoch time is 5 sec
  46. etime_base = 5
  47. clients_per_server = math.ceil(n/m)
  48. # Using 1 sec for ~50K clients in compute time
  49. # Using 8 sec for 2^20 clients in route_compute time as the base for calculations below
  50. # (About 1 sec actual route, 6.5 sec for storage generate_tokens
  51. # and process_msgs)
  52. etime_route_compute = 0.8 * math.ceil(clients_per_server/100000)
  53. etime_precompute = 1.5 * math.ceil(clients_per_server/100000)
  54. # If we have less than 3 threads the precompute happens sequentially
  55. # so epoch_interval needs to account for all the precompute
  56. #if(t < 3):
  57. # etime_precompute *=3
  58. # Client time:
  59. # Takes about 30 sec for handling 2^20 clients
  60. etime_client = math.ceil(clients_per_server/100000) * 3
  61. #if(t>3):
  62. # etime_client/=(t/4)
  63. #etime_inc = math.ceil(clients_per_server/25000)
  64. #etime_client = ((math.ceil(2/t))**2) * etime_inc
  65. etime = etime_base + etime_precompute + etime_route_compute + etime_client
  66. return int(etime)
  67. if __name__ == "__main__":
  68. if not os.path.exists(LOG_FOLDER):
  69. os.mkdir(LOG_FOLDER)
  70. for t in T:
  71. b = B
  72. m_start = 1
  73. # Set M_MAX depending on t
  74. m_end = M_MAX[t]
  75. for m in M:
  76. if(m <= m_end):
  77. for n in N:
  78. print("\n\n Running Experiment t = %d, m = %d, n = %d \n\n" % (t, m, n))
  79. generate_manifest(n, m, t, b)
  80. generate_config(n, m, t, b)
  81. epoch_interval = epoch_time(n, m, t, b)
  82. print("Epoch_interval = %d" % epoch_interval)
  83. log_subfolder = str(n) + "_" + str(m) + "_" + str(t) + "_" + str(b) + "/"
  84. log_subfolder = LOG_FOLDER + log_subfolder
  85. if not os.path.exists(log_subfolder):
  86. os.mkdir(log_subfolder)
  87. # Since launch is invoked from App/ ; we add a ../ to subfolder before
  88. # passing it to slaunch
  89. log_subfolder = "../" + log_subfolder
  90. slaunch = []
  91. slaunch.append("./launch")
  92. slaunch.append("route_clients")
  93. slaunch.append("-l")
  94. slaunch.append(log_subfolder)
  95. slaunch.append("-n")
  96. nodes_to_include = ["-n"]
  97. for i in range(1, m+1):
  98. nodes_to_include.append("s"+str(i))
  99. slaunch.append("s"+str(i))
  100. slaunch.append("-e")
  101. slaunch.append(str(epoch_interval))
  102. os.chdir("./App")
  103. # Server outputs are captured by log files provided to each of the server
  104. # launch calls made by App/launch
  105. make = subprocess.call(["make", "-C", "..", "-j"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
  106. server_process = subprocess.run(slaunch)
  107. claunch = []
  108. claunch.append("./clientlaunch")
  109. claunch.append("-t")
  110. claunch.append("8")
  111. claunch.append("-l")
  112. claunch.append(log_subfolder+"clients.log")
  113. os.chdir("./../Client/")
  114. client_process = subprocess.call(claunch)
  115. os.chdir("./../")