|
| 1 | +## Files in This Directory |
| 2 | + |
| 3 | +| File | Purpose | |
| 4 | +|------|---------| |
| 5 | +| `storage-class.yaml` | Defines Hyperdisk storage type (500GB capacity) | |
| 6 | +| `pvc.yaml` | Creates the persistent disk (500GB Hyperdisk) | |
| 7 | +| `batching-test.yaml` | Runs the batching comparison test | |
| 8 | +| `HOW_TO_RUN.md` | This guide | |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## Prerequisites |
| 13 | + |
| 14 | +### 1. **You must have kubectl access to the cluster:** |
| 15 | +```bash |
| 16 | +gcloud auth login |
| 17 | +gcloud container clusters get-credentials sequencer-dev --region us-central1 --project starkware-dev |
| 18 | +``` |
| 19 | + |
| 20 | +### 2. **Verify you can connect:** |
| 21 | +```bash |
| 22 | +kubectl cluster-info |
| 23 | +``` |
| 24 | + |
| 25 | +You should see: `Kubernetes control plane is running at https://...` |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +## Step-by-Step Instructions |
| 30 | + |
| 31 | +### **Step 1: Navigate to the directory** |
| 32 | + |
| 33 | +```bash |
| 34 | +cd /home/dean/workspace/sequencer/deployments/dean-batching |
| 35 | +``` |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +### **Step 2: Create the StorageClass (Hyperdisk type)** |
| 40 | + |
| 41 | +This defines **how** Kubernetes creates Hyperdisks. |
| 42 | + |
| 43 | +```bash |
| 44 | +kubectl apply -f storage-class.yaml |
| 45 | +``` |
| 46 | + |
| 47 | +**Expected output:** |
| 48 | +``` |
| 49 | +storageclass.storage.k8s.io/hyperdisk-balanced-500gb created |
| 50 | +``` |
| 51 | + |
| 52 | +--- |
| 53 | + |
| 54 | +### **Step 3: Create the PersistentVolumeClaim (request the disk)** |
| 55 | + |
| 56 | +This **actually creates** the 500GB Hyperdisk. |
| 57 | + |
| 58 | +```bash |
| 59 | +kubectl apply -f pvc.yaml |
| 60 | +``` |
| 61 | + |
| 62 | +**Expected output:** |
| 63 | +``` |
| 64 | +persistentvolumeclaim/dean-hyperdisk-pvc created |
| 65 | +``` |
| 66 | + |
| 67 | +**Check the PVC status:** |
| 68 | +```bash |
| 69 | +kubectl get pvc -n dean-batching |
| 70 | +``` |
| 71 | + |
| 72 | +You should see: |
| 73 | +``` |
| 74 | +NAME STATUS VOLUME CAPACITY STORAGECLASS AGE |
| 75 | +dean-hyperdisk-pvc Pending - - hyperdisk-balanced-500gb 10s |
| 76 | +``` |
| 77 | + |
| 78 | +**NOTE:** Status will be `Pending` until a pod uses it (this is normal with `WaitForFirstConsumer`). |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +### **Step 4: Create the namespace (if needed)** |
| 83 | + |
| 84 | +If the namespace doesn't exist: |
| 85 | + |
| 86 | +```bash |
| 87 | +kubectl create namespace dean-batching |
| 88 | +``` |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +### **Step 5: Create ConfigMap with node configs** |
| 93 | + |
| 94 | +The test needs configuration files. Check if they exist: |
| 95 | + |
| 96 | +```bash |
| 97 | +kubectl get configmap sequencer-configs -n dean-batching |
| 98 | +``` |
| 99 | + |
| 100 | +**If they DON'T exist, create them:** |
| 101 | + |
| 102 | +This requires the `deploy_batching_test.sh` script from the old directory. You can either: |
| 103 | + |
| 104 | +**Option A: Copy and run just the ConfigMap creation part:** |
| 105 | + |
| 106 | +```bash |
| 107 | +cd /home/dean/workspace/sequencer/deployments/batching-test |
| 108 | +bash -c ' |
| 109 | + source deploy_batching_test.sh |
| 110 | + NAMESPACE="dean-batching" |
| 111 | + create_config_files_configmap |
| 112 | +' |
| 113 | +``` |
| 114 | + |
| 115 | +**Option B: Manually check if they exist in the batching-test namespace:** |
| 116 | + |
| 117 | +```bash |
| 118 | +# Check if configs exist in old namespace |
| 119 | +kubectl get configmap sequencer-configs -n batching-test |
| 120 | + |
| 121 | +# If yes, copy them: |
| 122 | +kubectl get configmap sequencer-configs -n batching-test -o yaml | \ |
| 123 | + sed 's/namespace: batching-test/namespace: dean-batching/' | \ |
| 124 | + kubectl apply -f - |
| 125 | +``` |
| 126 | + |
| 127 | +--- |
| 128 | + |
| 129 | +### **Step 6: Deploy the test job** |
| 130 | + |
| 131 | +```bash |
| 132 | +kubectl apply -f batching-test.yaml |
| 133 | +``` |
| 134 | + |
| 135 | +**Expected output:** |
| 136 | +``` |
| 137 | +job.batch/dean-batching-test created |
| 138 | +``` |
| 139 | + |
| 140 | +--- |
| 141 | + |
| 142 | +### **Step 7: Monitor the test progress** |
| 143 | + |
| 144 | +**Check if the pod is running:** |
| 145 | + |
| 146 | +```bash |
| 147 | +kubectl get pods -n dean-batching |
| 148 | +``` |
| 149 | + |
| 150 | +You should see: |
| 151 | +``` |
| 152 | +NAME READY STATUS RESTARTS AGE |
| 153 | +dean-batching-test-xxxxx 1/1 Running 0 30s |
| 154 | +``` |
| 155 | + |
| 156 | +**Watch the logs in real-time:** |
| 157 | + |
| 158 | +```bash |
| 159 | +kubectl logs -f -n dean-batching -l app=dean-batching-test |
| 160 | +``` |
| 161 | + |
| 162 | +You'll see output like: |
| 163 | + |
| 164 | +``` |
| 165 | +========================================= |
| 166 | +DEAN'S BATCHING TEST: 0 → 50K |
| 167 | +========================================= |
| 168 | +
|
| 169 | +=== TEST 1: WITHOUT BATCHING === |
| 170 | +Starting sync WITHOUT batching from block 0... |
| 171 | +PID: 24 |
| 172 | +Monitoring progress (checking every 1 second)... |
| 173 | + Block 100 (5s elapsed) |
| 174 | + Block 250 (10s elapsed) |
| 175 | + Block 450 (15s elapsed) |
| 176 | + ... |
| 177 | + ✅ Reached target! Stopping at block 50001... |
| 178 | +
|
| 179 | +=== RESULT 1: WITHOUT BATCHING === |
| 180 | + Blocks synced: 50001 |
| 181 | + Time: 1834s (30m 34s) |
| 182 | + Speed: 27.27 blocks/sec |
| 183 | + Disk usage: 8.2G |
| 184 | +
|
| 185 | +Cleaning up for next test... |
| 186 | +
|
| 187 | +=== TEST 2: WITH BATCHING === |
| 188 | +Starting sync WITH batching from block 0... |
| 189 | +PID: 3425 |
| 190 | +Monitoring progress (checking every 1 second)... |
| 191 | + Block 150 (5s elapsed) |
| 192 | + Block 320 (10s elapsed) |
| 193 | + Block 510 (15s elapsed) |
| 194 | + ... |
| 195 | + Reached target! Stopping at block 50002... |
| 196 | +
|
| 197 | +=== RESULT 2: WITH BATCHING === |
| 198 | + Blocks synced: 50002 |
| 199 | + Time: 1245s (20m 45s) |
| 200 | + Speed: 40.16 blocks/sec |
| 201 | + Disk usage: 8.3G |
| 202 | +
|
| 203 | +========================================= |
| 204 | +FINAL COMPARISON |
| 205 | +========================================= |
| 206 | +
|
| 207 | +WITHOUT Batching: |
| 208 | + Blocks: 50001 |
| 209 | + Time: 1834s |
| 210 | + Speed: 27.27 blocks/sec |
| 211 | +
|
| 212 | +WITH Batching: |
| 213 | + Blocks: 50002 |
| 214 | + Time: 1245s |
| 215 | + Speed: 40.16 blocks/sec |
| 216 | +
|
| 217 | +WITH batching is 1.47x FASTER |
| 218 | + Speed improvement: 1.47x |
| 219 | +
|
| 220 | +NOTE: Blocks 0-50k are very small (~80 bytes each) |
| 221 | +Batching may add overhead on tiny blocks |
| 222 | +For fair comparison, test blocks 200k+ with real transactions |
| 223 | +
|
| 224 | +========================================= |
| 225 | +TEST COMPLETE |
| 226 | +========================================= |
| 227 | +``` |
| 228 | + |
| 229 | +--- |
| 230 | + |
| 231 | +### **Step 8: Check the results** |
| 232 | + |
| 233 | +After the test completes (20-60 minutes), review the final comparison: |
| 234 | + |
| 235 | +```bash |
| 236 | +kubectl logs -n dean-batching -l app=dean-batching-test | tail -50 |
| 237 | +``` |
| 238 | + |
| 239 | +--- |
| 240 | + |
| 241 | +## How to Stop or Delete the Test |
| 242 | + |
| 243 | +**Stop the running job:** |
| 244 | + |
| 245 | +```bash |
| 246 | +kubectl delete job dean-batching-test -n dean-batching |
| 247 | +``` |
| 248 | + |
| 249 | +**Delete the disk (WARNING: This deletes all data!):** |
| 250 | + |
| 251 | +```bash |
| 252 | +kubectl delete pvc dean-hyperdisk-pvc -n dean-batching |
| 253 | +``` |
| 254 | + |
| 255 | +**Delete the entire namespace (everything):** |
| 256 | + |
| 257 | +```bash |
| 258 | +kubectl delete namespace dean-batching |
| 259 | +``` |
| 260 | + |
| 261 | +--- |
| 262 | + |
| 263 | +## Troubleshooting |
| 264 | + |
| 265 | +### **Problem: Pod is stuck in "Pending" state** |
| 266 | + |
| 267 | +```bash |
| 268 | +kubectl describe pod -n dean-batching -l app=dean-batching-test |
| 269 | +``` |
| 270 | + |
| 271 | +**Common causes:** |
| 272 | +- **No c4d nodes available:** Wait 2-5 minutes for autoscaler to create nodes |
| 273 | +- **PVC not bound:** Check `kubectl get pvc -n dean-batching` |
| 274 | +- **Resource limits:** c4d-standard-8 has 8 vCPUs, pod requests 7 (leaving 1 for system) |
| 275 | + |
| 276 | +--- |
| 277 | + |
| 278 | +### **Problem: "Error from server (Unauthorized)"** |
| 279 | + |
| 280 | +Your kubectl credentials expired. Re-authenticate: |
| 281 | + |
| 282 | +```bash |
| 283 | +gcloud auth login |
| 284 | +gcloud container clusters get-credentials sequencer-dev --region us-central1 --project starkware-dev |
| 285 | +``` |
| 286 | + |
| 287 | +--- |
| 288 | + |
| 289 | +### **Problem: ConfigMap not found** |
| 290 | + |
| 291 | +The test needs `sequencer-configs` ConfigMap. Follow Step 5 above to create it. |
| 292 | + |
| 293 | +--- |
| 294 | + |
| 295 | +### **Problem: Test syncs too many blocks (goes past 50k)** |
| 296 | + |
| 297 | +Early blocks (0-50k) are very small and sync extremely fast. The monitoring script checks every 1 second, but hundreds of blocks can sync in that time. |
| 298 | + |
| 299 | +**This is expected behavior for early blocks!** |
| 300 | + |
| 301 | +For more accurate testing, test blocks 200k-250k where blocks contain real transaction data. |
| 302 | + |
| 303 | +--- |
| 304 | + |
| 305 | +## Understanding the Results |
| 306 | + |
| 307 | +### **What the numbers mean:** |
| 308 | + |
| 309 | +- **Blocks synced:** How many blocks were written to the database |
| 310 | +- **Time:** Total sync duration in seconds (and minutes) |
| 311 | +- **Speed:** Blocks per second (blocks/time) |
| 312 | +- **Disk usage:** Size of the database directory |
| 313 | + |
| 314 | +### **Interpreting the comparison:** |
| 315 | + |
| 316 | +- **1.5x faster:** Batching is 50% faster |
| 317 | +- **2.0x faster:** Batching is 100% faster (twice as fast) |
| 318 | +- **0.8x faster:** Batching is 20% slower (not faster!) |
| 319 | + |
| 320 | +### **Important note about blocks 0-50k:** |
| 321 | + |
| 322 | +These blocks are mostly **empty** (80 bytes each, no transactions). They download extremely fast from the network, so: |
| 323 | +- Batching may appear slower due to overhead |
| 324 | +- Network speed dominates over disk I/O |
| 325 | +- **Fair comparison requires blocks 200k+ with real transactions** |
| 326 | + |
| 327 | +--- |
| 328 | + |
| 329 | +## Summary: Quick Commands |
| 330 | + |
| 331 | +```bash |
| 332 | +# 1. Navigate to directory |
| 333 | +cd /home/dean/workspace/sequencer/deployments/dean-batching |
| 334 | + |
| 335 | +# 2. Create everything (StorageClass, PVC, Namespace, Job) |
| 336 | +kubectl apply -f storage-class.yaml |
| 337 | +kubectl apply -f pvc.yaml |
| 338 | +kubectl create namespace dean-batching # if needed |
| 339 | +# (Create ConfigMap - see Step 5) |
| 340 | +kubectl apply -f batching-test.yaml |
| 341 | + |
| 342 | +# 3. Watch the test |
| 343 | +kubectl logs -f -n dean-batching -l app=dean-batching-test |
| 344 | + |
| 345 | +# 4. Check results |
| 346 | +kubectl logs -n dean-batching -l app=dean-batching-test | tail -50 |
| 347 | + |
| 348 | +# 5. Clean up (delete everything) |
| 349 | +kubectl delete job dean-batching-test -n dean-batching |
| 350 | +kubectl delete pvc dean-hyperdisk-pvc -n dean-batching |
| 351 | +kubectl delete storageclass hyperdisk-balanced-500gb |
| 352 | +``` |
| 353 | + |
| 354 | +--- |
0 commit comments