gen_manifest.py 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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):
  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: 1
  24. # The number of private messages each user can receive per epoch
  25. priv_in: 1
  26. # The number of public messages each user can send per epoch
  27. pub_out: 2
  28. # The number of public messages each user can receive per epoch
  29. pub_in: 2
  30. # A hardcoded master secret for generating keys to bootstrap
  31. # client -> server communications
  32. master_secret: \"AHardCodedAESKey\"\n'''.format(N = str(N), B = str(B))
  33. # print (manifest_params)
  34. mf.write(manifest_params)
  35. server_params = '''\ns{i}:
  36. sprvfile: keys/priv.seal.s{i}
  37. pubfile: keys/pub.s{i}
  38. weight: 1
  39. listen: 127.0.0.{i}:12500
  40. clisten: 127.0.0.{i}:13000
  41. slisten: 127.0.0.{i}:13001
  42. launchprefix: numactl {nstring}
  43. args: -t {T}
  44. roles: 7\n'''
  45. # Assign server threads starting at 0
  46. numa_base = 0
  47. # Do not assign servers threads that are across the processors
  48. numa_limit = 36
  49. numa_start = numa_base
  50. for s in range(1, M+1):
  51. numa_end = numa_start + T -1
  52. if(numa_start < numa_limit and numa_end > numa_limit):
  53. numa_start = 40
  54. numa_end = numa_start + T
  55. numa_string = "-C{s}-{e}".format(s = str(numa_start), e = str(numa_end))
  56. numa_start = numa_end + 1
  57. curr_params = server_params.format(i = str(s), nstring = numa_string, T = str(T))
  58. # print(curr_params)
  59. mf.write(curr_params)
  60. mf.close()
  61. if __name__ == "__main__":
  62. if(len(sys.argv)!=5):
  63. print("Incorrect usage!\n Expects 4 parameters. n,m,t,b")
  64. exit()
  65. n = int(sys.argv[1])
  66. m = int(sys.argv[2])
  67. t = int(sys.argv[3])
  68. b = int(sys.argv[4])
  69. generate_manifest(n, m, t, b)