submap_scaling.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import os
  2. import subprocess
  3. SENDS = 1048576
  4. FETCHES = 8192
  5. USERS = FETCHES
  6. THREADS = 8
  7. MAP_THREADS = [(i, THREADS * i + THREADS) for i in range(1, int(48 / THREADS))]
  8. RUNS = 10
  9. WARMUP = 0
  10. DATA_DIR = os.path.join(os.getcwd(), "data", "submap-scaling")
  11. os.makedirs(DATA_DIR, exist_ok=True)
  12. SPARTA_DIR = os.path.join(os.getcwd(), "sparta")
  13. BASELINE_DIR = os.path.join(os.getcwd(), "baseline")
  14. BASELINE_FILE = os.path.join(DATA_DIR, f"baseline-{FETCHES}-{THREADS}.csv")
  15. SPARTA_FILE = os.path.join(DATA_DIR, f"sparta-{FETCHES}-{THREADS}.csv")
  16. def sparta_cmd(mt):
  17. (num_maps, num_threads) = mt
  18. cmd = ["cargo", "run", "--release", "--",
  19. str(SENDS), str(FETCHES), str(num_threads),
  20. str(USERS), str(num_maps), "-r", str(RUNS), "-w", str(WARMUP)]
  21. result = subprocess.run(cmd, capture_output=True,
  22. text=True, cwd=SPARTA_DIR)
  23. return result.stdout
  24. def baseline_cmd(mt):
  25. (_num_maps, num_threads) = mt
  26. cmd = ["cargo", "run", "--release", "--",
  27. str(SENDS), str(FETCHES), str(num_threads), "-r", str(RUNS), "-w", str(WARMUP)]
  28. result = subprocess.run(cmd, capture_output=True,
  29. text=True, cwd=BASELINE_DIR)
  30. return result.stdout
  31. for mt in MAP_THREADS:
  32. print(mt)
  33. with open(SPARTA_FILE, "a") as sparta_file:
  34. output = sparta_cmd(mt)
  35. print("\tsparta:", output)
  36. sparta_file.write(output)
  37. with open(BASELINE_FILE, "a") as baseline_file:
  38. output = baseline_cmd(mt)
  39. print("\tbaseline:", output)
  40. baseline_file.write(output)