run_experiments.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #!/usr/bin/python3
  2. '''
  3. NOTE: This script is tailored for a machine with 2 40-core processors.
  4. Currently assumes 8 threads (C36-39,76-79) are set aside for client
  5. simulator; change this by setting "prefix" in Client/clientlaunch and
  6. the -t option to clientlaunch below.
  7. Similarly, the use of cores C0-35,40-75 for the TEEMS servers can be
  8. changed in the gen_manifest.py program.
  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_test/"
  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, 32, 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 15 sec
  46. etime_base = 15
  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. # Costs for Waksman network precompute
  55. # Public routing needs 5 WN, private routing needs 3 WNs
  56. etime_precompute *=5
  57. # Client time:
  58. # Takes about 30 sec for handling 2^20 clients
  59. etime_client = math.ceil(clients_per_server/100000) * 5
  60. etime = etime_base + etime_precompute + etime_route_compute + etime_client
  61. return int(etime)
  62. if __name__ == "__main__":
  63. if not os.path.exists(LOG_FOLDER):
  64. os.mkdir(LOG_FOLDER)
  65. for t in T:
  66. b = B
  67. m_start = 1
  68. # Set M_MAX depending on t
  69. m_end = M_MAX[t]
  70. for m in M:
  71. if(m <= m_end):
  72. for n in N:
  73. print("\n\n Running Experiment t = %d, m = %d, n = %d \n\n" % (t, m, n))
  74. generate_manifest(n, m, t, b)
  75. generate_config(n, m, t, b)
  76. epoch_interval = epoch_time(n, m, t, b)
  77. print("Epoch_interval = %d" % epoch_interval)
  78. log_subfolder = str(n) + "_" + str(m) + "_" + str(t) + "_" + str(b) + "/"
  79. log_subfolder = LOG_FOLDER + log_subfolder
  80. if not os.path.exists(log_subfolder):
  81. os.mkdir(log_subfolder)
  82. # Since launch is invoked from App/ ; we add a ../ to subfolder before
  83. # passing it to slaunch
  84. log_subfolder = "../" + log_subfolder
  85. slaunch = []
  86. slaunch.append("./launch")
  87. slaunch.append("route_clients")
  88. slaunch.append("-l")
  89. slaunch.append(log_subfolder)
  90. slaunch.append("-n")
  91. nodes_to_include = ["-n"]
  92. for i in range(1, m+1):
  93. nodes_to_include.append("s"+str(i))
  94. slaunch.append("s"+str(i))
  95. slaunch.append("-e")
  96. slaunch.append(str(epoch_interval))
  97. os.chdir("./App")
  98. # Server outputs are captured by log files provided to each of the server
  99. # launch calls made by App/launch
  100. make = subprocess.call(["make", "-C", "..", "-j"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
  101. try:
  102. os.mkdir("keys")
  103. except:
  104. # It's OK if it already exists
  105. pass
  106. pubkeys = subprocess.call(["./getpubkeys"])
  107. server_process = subprocess.run(slaunch)
  108. claunch = []
  109. claunch.append("./clientlaunch")
  110. claunch.append("-t")
  111. claunch.append("8")
  112. claunch.append("-l")
  113. claunch.append(log_subfolder+"clients.log")
  114. os.chdir("./../Client/")
  115. client_process = subprocess.call(claunch)
  116. os.chdir("./../")