gen_manifest.py 2.2 KB

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