gen_manifest.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. #!/usr/bin/python3
  2. import subprocess
  3. import os
  4. import sys
  5. import math
  6. # CONFIGS TO SET:
  7. MANIFEST_FILE = "App/manifest.yaml"
  8. '''
  9. Generate a manifest file with:
  10. N: number of clients
  11. M: number of servers
  12. T: number of threads for each server
  13. B: msg_size
  14. '''
  15. def generate_manifest(N, M, T, B, PRIVATE_ROUTE = True, priv_out=1, priv_in=1, pub_out=1, pub_in=1):
  16. mf = open(MANIFEST_FILE, 'w+')
  17. manifest_params = '''params:
  18. # The total max number of users
  19. user_count: {N}
  20. # The size of a message in bytes
  21. msg_size: {B}
  22. # The number of private messages each user can send per epoch
  23. priv_out: {pro}
  24. # The number of private messages each user can receive per epoch
  25. priv_in: {pri}
  26. # The number of public messages each user can send per epoch
  27. pub_out: {puo}
  28. # The number of public messages each user can receive per epoch
  29. pub_in: {pui}
  30. # Private or public routing protocol selection
  31. private_routing: {PRIVATE_ROUTE}
  32. # A hardcoded master secret for generating keys to bootstrap
  33. # client -> server communications
  34. master_secret: \"AHardCodedAESKey\"\n'''.format(N = str(N), B = str(B), PRIVATE_ROUTE=str(PRIVATE_ROUTE),\
  35. pro = str(priv_out), pri = str(priv_in), puo = str(pub_out), pui = str(pub_in))
  36. # print (manifest_params)
  37. mf.write(manifest_params)
  38. server_params = '''\ns{i}:
  39. sprvfile: keys/priv.seal.s{i}
  40. pubfile: keys/pub.s{i}
  41. weight: 1
  42. listen: 127.0.0.{i}:12500
  43. clisten: 127.0.0.{i}:13000
  44. slisten: 127.0.0.{i}:13001
  45. launchprefix: numactl {nstring}
  46. args: -t {T}
  47. roles: 7\n'''
  48. # Assign server threads starting at 0
  49. numa_base = 0
  50. # Do not assign servers threads that are across the processors
  51. numa_limit = 36
  52. numa_start = numa_base
  53. for s in range(1, M+1):
  54. numa_end = numa_start + T -1
  55. if(numa_start <= numa_limit and numa_end > numa_limit):
  56. numa_start = 40
  57. numa_end = numa_start + T
  58. numa_string = "-C{s}-{e}".format(s = str(numa_start), e = str(numa_end))
  59. numa_start = numa_end + 1
  60. curr_params = server_params.format(i = str(s), nstring = numa_string, T = str(T))
  61. # print(curr_params)
  62. mf.write(curr_params)
  63. mf.close()
  64. if __name__ == "__main__":
  65. if(len(sys.argv)!=5):
  66. print("Incorrect usage!\n Expects 4 parameters. n,m,t,b")
  67. exit()
  68. n = int(sys.argv[1])
  69. m = int(sys.argv[2])
  70. t = int(sys.argv[3])
  71. b = int(sys.argv[4])
  72. generate_manifest(n, m, t, b)