run_experiments.py 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. If you have a different number of cores available for servers, also
  10. change M_MAX below.
  11. '''
  12. import subprocess
  13. import os
  14. import sys
  15. import math
  16. from gen_manifest import generate_manifest
  17. from gen_enclave_config import generate_config
  18. ###############################################################################
  19. # CONFIGS TO SET:
  20. MANIFEST_FILE = "App/manifest.yaml"
  21. LOG_FOLDER = "Experiments_test/"
  22. # N = number of clients
  23. # M = number of servers
  24. # T = threads per server instance
  25. ## A large grid of many combinations
  26. # N = [1<<16, 1<<17, 1<<18, 1<<19, 1<<20]
  27. # M = [72, 64, 48, 36, 32, 24, 16, 8, 4, 2, 1]
  28. # T = [16, 8, 4, 2, 1]
  29. ## Figure 7
  30. N = [1<<15, 1<<16, 1<<17, 1<<18, 1<<19, 1<<20]
  31. M = [4]
  32. T = [1]
  33. ## Figure 8
  34. # N = [1<<20]
  35. # M = [72, 64, 48, 36, 32, 24, 16, 8, 4, 2, 1]
  36. # T = [1]
  37. # Max servers depending on number of threads (assuming 72 available
  38. # cores for servers)
  39. M_MAX = {
  40. 1:72,
  41. 2:36,
  42. 4:18,
  43. 8:9,
  44. 16:4
  45. }
  46. # B = message size (bytes)
  47. B = 256
  48. ###############################################################################
  49. def epoch_time(n, m, t, b):
  50. # Base epoch time is 15 sec
  51. etime_base = 15
  52. clients_per_server = math.ceil(n/m)
  53. # Using 1 sec for ~50K clients in compute time
  54. # Using 8 sec for 2^20 clients in route_compute time as the base for calculations below
  55. # (About 1 sec actual route, 6.5 sec for storage generate_tokens
  56. # and process_msgs)
  57. etime_route_compute = 0.8 * math.ceil(clients_per_server/100000)
  58. etime_precompute = 1.5 * math.ceil(clients_per_server/100000)
  59. # Costs for Waksman network precompute
  60. # Public routing needs 5 WN, private routing needs 3 WNs
  61. etime_precompute *=5
  62. # Client time:
  63. # Takes about 30 sec for handling 2^20 clients
  64. etime_client = math.ceil(clients_per_server/100000) * 5
  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. try:
  107. os.mkdir("keys")
  108. except:
  109. # It's OK if it already exists
  110. pass
  111. pubkeys = subprocess.call(["./getpubkeys"])
  112. server_process = subprocess.run(slaunch)
  113. claunch = []
  114. claunch.append("./clientlaunch")
  115. claunch.append("-t")
  116. claunch.append("8")
  117. claunch.append("-l")
  118. claunch.append(log_subfolder+"clients.log")
  119. os.chdir("./../Client/")
  120. client_process = subprocess.call(claunch)
  121. os.chdir("./../")