-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
1796 lines (1676 loc) · 76.4 KB
/
Copy pathindex.html
File metadata and controls
1796 lines (1676 loc) · 76.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cache Effectiveness & Tail Latency — Research Dashboard v1.2</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.min.js"></script>
<style>
:root {
--bg: #0b0d14;
--surface: #13161f;
--surface2: #1c2030;
--surface3: #222840;
--border: #2a2f45;
--text: #e8eaf0;
--muted: #7a80a0;
--dim: #4a5070;
--no: #f87171;
--lru: #6c8fff;
--part: #34d399;
--aff: #fb923c;
--accent: #6c8fff;
--accent2: #34d399;
--warn: #f59e0b;
--radius: 12px;
--radius-sm: 8px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
background: var(--bg);
color: var(--text);
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
font-size: 14px;
line-height: 1.6;
min-height: 100vh;
}
/* ── HEADER ── */
.header {
background: linear-gradient(135deg, #13161f 0%, #1a1d2e 100%);
border-bottom: 1px solid var(--border);
padding: 20px 24px;
display: flex;
justify-content: space-between;
align-items: flex-start;
gap: 16px;
flex-wrap: wrap;
}
.header-left h1 {
font-size: 16px;
font-weight: 700;
line-height: 1.4;
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.header-left p {
color: var(--muted);
font-size: 12px;
margin-top: 5px;
max-width: 560px;
}
.version-badge {
background: rgba(108, 143, 255, 0.2);
color: var(--accent);
padding: 2px 8px;
border-radius: 20px;
font-size: 10px;
font-weight: 700;
letter-spacing: .04em;
border: 1px solid rgba(108,143,255,.3);
}
.header-right {
text-align: right;
font-size: 12px;
color: var(--muted);
line-height: 2;
flex-shrink: 0;
}
.header-right strong { color: var(--text); font-size: 13px; }
.pill-tag {
display: inline-block;
background: rgba(52, 211, 153, 0.15);
color: var(--accent2);
padding: 1px 8px;
border-radius: 20px;
font-size: 10px;
font-weight: 600;
border: 1px solid rgba(52,211,153,.25);
}
/* ── TABS ── */
.tabs-wrapper {
background: var(--surface);
border-bottom: 1px solid var(--border);
overflow-x: auto;
-webkit-overflow-scrolling: touch;
scrollbar-width: none;
}
.tabs-wrapper::-webkit-scrollbar { display: none; }
.tabs {
display: flex;
padding: 12px 20px 0;
gap: 2px;
min-width: max-content;
}
.tab {
padding: 8px 16px;
border-radius: 8px 8px 0 0;
cursor: pointer;
font-size: 12px;
font-weight: 500;
color: var(--muted);
border: 1px solid transparent;
border-bottom: none;
transition: all .15s ease;
white-space: nowrap;
user-select: none;
}
.tab:hover { color: var(--text); background: var(--surface2); }
.tab.active { color: var(--text); background: var(--bg); border-color: var(--border); }
/* ── PANELS ── */
.panel { display: none; padding: 20px; }
.panel.active { display: block; }
/* ── GRIDS ── */
.grid1 { display: grid; grid-template-columns: 1fr; gap: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.full { grid-column: 1 / -1; }
/* ── CARDS ── */
.card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 18px;
transition: border-color .2s;
}
.card:hover { border-color: var(--surface3); }
.card h3 {
font-size: 11px;
font-weight: 600;
color: var(--muted);
text-transform: uppercase;
letter-spacing: .06em;
margin-bottom: 16px;
}
/* ── STAT CARDS ── */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 16px;
position: relative;
overflow: hidden;
}
.stat::before {
content: '';
position: absolute;
top: 0; left: 0; right: 0;
height: 2px;
}
.stat.c-green::before { background: linear-gradient(90deg, var(--part), transparent); }
.stat.c-blue::before { background: linear-gradient(90deg, var(--lru), transparent); }
.stat.c-orange::before { background: linear-gradient(90deg, var(--aff), transparent); }
.stat.c-red::before { background: linear-gradient(90deg, var(--no), transparent); }
.stat-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 28px; font-weight: 800; margin-top: 4px; line-height: 1; }
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 5px; line-height: 1.4; }
/* ── FINDINGS ── */
.findings-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 14px;
}
.finding {
background: var(--surface2);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
padding: 16px;
transition: transform .2s, border-color .2s;
}
.finding:hover { transform: translateY(-2px); border-color: var(--surface3); }
.finding .num { font-size: 28px; font-weight: 900; color: var(--accent); margin-bottom: 6px; opacity: .8; }
.finding .title { font-size: 13px; font-weight: 600; margin-bottom: 7px; }
.finding .body { font-size: 12px; color: var(--muted); line-height: 1.7; }
.finding.warn-card { border-color: rgba(248,113,113,.25); background: rgba(248,113,113,.04); }
.finding.warn-card .num { color: var(--no); }
/* ── LEGEND ── */
.legend-row {
display: flex;
gap: 16px;
flex-wrap: wrap;
align-items: center;
margin-bottom: 16px;
padding: 10px 14px;
background: var(--surface2);
border-radius: var(--radius-sm);
border: 1px solid var(--border);
}
.leg-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.leg-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.legend-note { font-size: 11px; color: var(--dim); margin-left: auto; }
/* ── INSIGHT BOX ── */
.insight {
background: rgba(108,143,255,.06);
border-left: 3px solid var(--accent);
padding: 12px 14px;
border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
margin-top: 14px;
font-size: 12px;
color: var(--muted);
line-height: 1.7;
}
.insight strong { color: var(--text); }
.honest-box {
background: rgba(248,113,113,.05);
border: 1px solid rgba(248,113,113,.2);
border-radius: var(--radius-sm);
padding: 12px 14px;
margin-bottom: 18px;
font-size: 12px;
color: var(--muted);
line-height: 1.7;
}
.honest-box strong { color: var(--no); }
/* ── CANVAS ── */
.chart-wrap { position: relative; width: 100%; }
canvas { width: 100% !important; display: block; }
/* ── TABLE ── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 640px; }
thead { background: var(--surface2); }
th {
padding: 10px 12px;
color: var(--muted);
font-weight: 500;
font-size: 10px;
text-transform: uppercase;
letter-spacing: .05em;
border-bottom: 1px solid var(--border);
text-align: left;
white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: var(--surface2); }
/* ── BADGE ── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 5px; font-size: 10px; font-weight: 700; letter-spacing: .03em; }
.b-no { background: rgba(248,113,113,.15); color: var(--no); }
.b-lru { background: rgba(108,143,255,.15); color: var(--lru); }
.b-part { background: rgba(52,211,153,.15); color: var(--part); }
.b-aff { background: rgba(251,146,60,.15); color: var(--aff); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
/* ── SLIDER ── */
.slider-wrap {
display: flex;
align-items: center;
gap: 14px;
padding: 12px 16px;
background: var(--surface2);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
margin-bottom: 16px;
flex-wrap: wrap;
}
.slider-wrap label { font-size: 12px; color: var(--muted); white-space: nowrap; }
.slider-wrap input[type=range] { flex: 1; min-width: 120px; accent-color: var(--accent); cursor: pointer; }
.slider-val { font-size: 13px; font-weight: 700; color: var(--accent); white-space: nowrap; min-width: 110px; text-align: right; }
/* ── COMPARISON ROW ── */
.compare-row {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 10px;
margin-bottom: 18px;
}
.compare-card {
background: var(--surface2);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
padding: 14px;
text-align: center;
}
.compare-card .cfg-name { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.compare-card .cfg-val { font-size: 22px; font-weight: 800; }
.compare-card .cfg-sub { font-size: 10px; color: var(--muted); margin-top: 3px; }
.compare-card.best { border-color: rgba(52,211,153,.4); background: rgba(52,211,153,.05); }
/* ── DIVIDER ── */
.section-label {
font-size: 10px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: .08em;
color: var(--dim);
padding: 0 2px;
margin: 20px 0 12px;
display: flex;
align-items: center;
gap: 10px;
}
.section-label::after {
content: '';
flex: 1;
height: 1px;
background: var(--border);
}
/* ── RESPONSIVE ── */
@media (max-width: 900px) {
.grid2, .grid3 { grid-template-columns: 1fr; }
.stats { grid-template-columns: 1fr 1fr; }
.findings-grid { grid-template-columns: 1fr; }
.grid4, .compare-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
.header { padding: 16px; }
.header h1 { font-size: 14px; }
.header-right { text-align: left; }
.panel { padding: 14px; }
.stats { grid-template-columns: 1fr 1fr; gap: 10px; }
.stat-value { font-size: 22px; }
.grid2, .grid3, .grid4, .compare-row { grid-template-columns: 1fr; }
.findings-grid { grid-template-columns: 1fr; }
.legend-note { margin-left: 0; width: 100%; }
.card { padding: 14px; }
}
@media (max-width: 400px) {
.stats { grid-template-columns: 1fr; }
}
</style>
</head>
<body>
<!-- HEADER -->
<div class="header">
<div class="header-left">
<h1>
Cache Effectiveness & Tail Latency
<span class="version-badge">v1.2</span>
</h1>
<p>When does partitioned caching outperform shared LRU due to locality concentration — and when does global LRU win from cross-client reuse?</p>
</div>
<div class="header-right">
<strong>Harish Yerraguntla</strong><br>
MS CS · SUNY New Paltz (GPA 3.81)<br>
Software Engineer · Qualcomm<br>
<span class="pill-tag">PhD Applicant — University of Rochester</span>
</div>
</div>
<!-- TABS -->
<div class="tabs-wrapper">
<div class="tabs">
<div class="tab active" onclick="switchTab('findings',this)">Key Findings</div>
<div class="tab" onclick="switchTab('concurrency',this)">Concurrency Sweep</div>
<div class="tab" onclick="switchTab('alpha',this)">Zipf Alpha</div>
<div class="tab" onclick="switchTab('mrc',this)">Miss Ratio Curves</div>
<div class="tab" onclick="switchTab('locality',this)">Locality Shift</div>
<div class="tab" onclick="switchTab('table',this)">Full Data Table</div>
<div class="tab" onclick="switchTab('trace',this)">Trace Validation</div>
<div class="tab" onclick="switchTab('crossover',this)" style="color:var(--accent2); font-weight:600;">Crossover Analysis ✦</div>
</div>
</div>
<!-- ════════════════ FINDINGS ════════════════ -->
<div class="panel active" id="panel-findings">
<div class="stats">
<div class="stat c-green">
<div class="stat-label">P95 Reduction vs No-Cache (10K)</div>
<div class="stat-value" style="color:var(--part)">95.3%</div>
<div class="stat-sub">4,617ms → 183ms · partitioned cache</div>
</div>
<div class="stat c-blue">
<div class="stat-label">Partitioned vs LRU Advantage at 50K</div>
<div class="stat-value" style="color:var(--lru)">27.5%</div>
<div class="stat-sub">482ms → 350ms P95 · queue dispersion wins</div>
</div>
<div class="stat c-orange">
<div class="stat-label">Client Affinity Hit-Rate Cost</div>
<div class="stat-value" style="color:var(--aff)">−18.7pp</div>
<div class="stat-sub">69.6% vs 88.3% · small per-client caches miss the tail</div>
</div>
<div class="stat c-red">
<div class="stat-label">MRC Shift: 1 → 20 Clients</div>
<div class="stat-value" style="color:var(--no)">+23.1pp</div>
<div class="stat-sub">Miss rate at 10% cache: 4.1% → 27.2%</div>
</div>
</div>
<div class="section-label">5 Key Results from 220 Simulation Trials</div>
<div class="findings-grid">
<div class="finding">
<div class="num">01</div>
<div class="title">LRU wins on P50. Partitioned wins on P95 at scale.</div>
<div class="body">Shared LRU achieves 2.1ms P50 — hot keys stay warm globally. Above 5K concurrency, P95 diverges: partitioned cache reduces miss-induced queue spikes per shard, yielding 15–27% lower P95 vs LRU from 10K to 50K requests.</div>
</div>
<div class="finding">
<div class="num">02</div>
<div class="title">Client affinity trades hit rate for isolation.</div>
<div class="body">CLIENT_AFFINITY routes each session to a dedicated node. At 10% total cache, per-node capacity is too small for the global tail — hit rate drops to 69.6%. This makes it worse than both LRU and partitioned on P95 at moderate concurrency.</div>
</div>
<div class="finding">
<div class="num">03</div>
<div class="title">Alpha is the primary predictor of cache value.</div>
<div class="body">At alpha=0.8, LRU hits only 41.4% — P50 stays above 100ms. At alpha=1.3 (Twitter-typical), LRU reaches 88.3% with P50=2.1ms. High-alpha workloads extract most locality value from tiny caches; low-alpha workloads see diminishing cache returns.</div>
</div>
<div class="finding">
<div class="num">04</div>
<div class="title">Concurrency genuinely shifts locality structure. <span style="font-size:10px;color:var(--accent);font-weight:700">v1.2</span></div>
<div class="body">Multi-client streams with disjoint hot subsets expand the working set a global LRU must cover. Miss rate at 10% cache grows from 4.1% (1 client) to 27.2% (20 clients). This is the mechanism by which partitioned caches can outperform LRU — not just contention, but reduced reuse distance per partition.</div>
</div>
<div class="finding">
<div class="num">05</div>
<div class="title">Error rates are the clearest case for any caching.</div>
<div class="body">No-cache collapses at 5K+ concurrency: 42% error rate at 5K, 91.6% at 50K. Every caching strategy keeps errors below 2.2% up to 50K. The P95 architecture debate is only meaningful after this baseline is established.</div>
</div>
<div class="finding warn-card">
<div class="num">⚠</div>
<div class="title">Honest scope of this simulation</div>
<div class="body">Throughput is effective throughput under a lognormal latency model, not wall-clock measurement. Queue contention is approximated via exponential wait — not a proper M/M/c model. Results are directionally valid; next step is validation against real Redis traces (Twitter OSDI 2020 dataset).</div>
</div>
</div>
<div class="section-label">At a Glance — 10K Concurrency, Alpha=1.3</div>
<div class="compare-row">
<div class="compare-card">
<div class="cfg-name" style="color:var(--no)">No Cache</div>
<div class="cfg-val" style="color:var(--no)">4,617ms</div>
<div class="cfg-sub">P95 · 64.6% error rate</div>
</div>
<div class="compare-card">
<div class="cfg-name" style="color:var(--lru)">LRU Cache</div>
<div class="cfg-val" style="color:var(--lru)">214ms</div>
<div class="cfg-sub">P95 · 88.3% hit rate</div>
</div>
<div class="compare-card best">
<div class="cfg-name" style="color:var(--part)">Partitioned ✓</div>
<div class="cfg-val" style="color:var(--part)">183ms</div>
<div class="cfg-sub">P95 · 88.2% hit rate · best tail</div>
</div>
<div class="compare-card">
<div class="cfg-name" style="color:var(--aff)">Client Affinity</div>
<div class="cfg-val" style="color:var(--aff)">266ms</div>
<div class="cfg-sub">P95 · 69.6% hit rate</div>
</div>
</div>
</div>
<!-- ════════════════ CONCURRENCY ════════════════ -->
<div class="panel" id="panel-concurrency">
<div class="legend-row">
<div class="leg-item"><div class="leg-dot" style="background:var(--no)"></div>No Cache</div>
<div class="leg-item"><div class="leg-dot" style="background:var(--lru)"></div>LRU Cache (Redis)</div>
<div class="leg-item"><div class="leg-dot" style="background:var(--part)"></div>Partitioned Cache</div>
<div class="leg-item"><div class="leg-dot" style="background:var(--aff)"></div>Client Affinity</div>
<div class="legend-note">Error bars = 95% CI over 5 trials · alpha = 1.3</div>
</div>
<div class="grid2">
<div class="card full">
<h3>P95 Latency vs Concurrency — Log Scale (ms)</h3>
<div class="chart-wrap" style="height:280px">
<canvas id="c-conc-p95"></canvas>
</div>
<div class="insight">
<strong>Key observation:</strong> No-cache collapses catastrophically above 1K concurrency. LRU and Partitioned diverge above 5K — equal hit rates, different backend queue pressure. Partitioned distributes miss load across shards; LRU funnels all misses through a single backend queue.
</div>
</div>
<div class="card">
<h3>P50 Latency vs Concurrency (ms)</h3>
<div class="chart-wrap" style="height:240px">
<canvas id="c-conc-p50"></canvas>
</div>
</div>
<div class="card">
<h3>Error Rate vs Concurrency (%)</h3>
<div class="chart-wrap" style="height:240px">
<canvas id="c-conc-err"></canvas>
</div>
</div>
<div class="card">
<h3>Backend Hit Rate vs Concurrency (%)</h3>
<div class="chart-wrap" style="height:240px">
<canvas id="c-conc-backend"></canvas>
</div>
</div>
<div class="card">
<h3>P95 Gap: Partitioned vs LRU (ms)</h3>
<div class="chart-wrap" style="height:240px">
<canvas id="c-conc-gap"></canvas>
</div>
</div>
</div>
</div>
<!-- ════════════════ ALPHA ════════════════ -->
<div class="panel" id="panel-alpha">
<div class="grid2">
<div class="card full">
<h3>P95 Latency vs Zipf Alpha — Concurrency = 10,000</h3>
<div class="chart-wrap" style="height:280px">
<canvas id="c-alpha-p95"></canvas>
</div>
<div class="insight">
<strong>Alpha is the lever:</strong> At alpha=1.5, Partitioned and LRU nearly converge (77ms vs 85ms, 94%+ hit). At alpha=0.8, all configs struggle — hit rates collapse to ~41% and P95 stays above 300ms. Client Affinity suffers most at low alpha because disjoint hot subsets stop being meaningful when the distribution is nearly flat.
</div>
</div>
<div class="card">
<h3>Hit Rate vs Zipf Alpha (%)</h3>
<div class="chart-wrap" style="height:240px">
<canvas id="c-alpha-hit"></canvas>
</div>
</div>
<div class="card">
<h3>P50 Latency vs Alpha (ms)</h3>
<div class="chart-wrap" style="height:240px">
<canvas id="c-alpha-p50"></canvas>
</div>
</div>
</div>
<div class="section-label">Hit Rate at Each Alpha Level</div>
<div class="grid3">
<div class="card" style="text-align:center">
<h3>Alpha = 0.8 (flat)</h3>
<div style="font-size:32px;font-weight:800;color:var(--no);margin:8px 0">41.4%</div>
<div style="font-size:11px;color:var(--muted)">LRU hit rate · P95 = 393ms</div>
</div>
<div class="card" style="text-align:center">
<h3>Alpha = 1.3 (Twitter-typical)</h3>
<div style="font-size:32px;font-weight:800;color:var(--lru);margin:8px 0">88.3%</div>
<div style="font-size:11px;color:var(--muted)">LRU hit rate · P95 = 214ms</div>
</div>
<div class="card" style="text-align:center">
<h3>Alpha = 1.5 (highly skewed)</h3>
<div style="font-size:32px;font-weight:800;color:var(--part);margin:8px 0">94.6%</div>
<div style="font-size:11px;color:var(--muted)">LRU hit rate · P95 = 85ms</div>
</div>
</div>
</div>
<!-- ════════════════ MRC ════════════════ -->
<div class="panel" id="panel-mrc">
<div class="card full">
<h3>Miss Ratio Curves by Zipf Alpha — How Fast Does Adding Cache Help?</h3>
<div class="chart-wrap" style="height:320px">
<canvas id="c-mrc-alpha"></canvas>
</div>
<div class="insight">
<strong>Connection to Ding TOMPECS'25:</strong> These MRCs are the empirical counterpart to the continuous-time Zipfian locality model. His model predicts miss rate as a differentiable, closed-form function of cache size. These curves validate the shape — steep initial drop, then a long plateau. Higher alpha = faster initial drop = more locality value per unit cache. At alpha=1.5, just 2% of key space gets you below 10% miss rate.
</div>
</div>
<div class="section-label">Summary Statistics from MRC</div>
<div class="grid2">
<div class="card">
<h3>Miss Rate at 10% Cache Size by Alpha</h3>
<div class="chart-wrap" style="height:240px">
<canvas id="c-mrc-10pct"></canvas>
</div>
</div>
<div class="card">
<h3>Cache Keys Needed to Reach 5% Miss Rate</h3>
<div class="chart-wrap" style="height:240px">
<canvas id="c-mrc-target"></canvas>
</div>
</div>
</div>
<div class="section-label">MRC Crossover Points</div>
<div class="grid4" style="grid-template-columns:repeat(4,1fr)">
<div class="card" style="text-align:center">
<h3>Alpha 0.8</h3>
<div style="font-size:26px;font-weight:800;color:var(--no);margin:8px 0">10.2%</div>
<div style="font-size:11px;color:var(--muted)">miss at 10% cache</div>
</div>
<div class="card" style="text-align:center">
<h3>Alpha 1.0</h3>
<div style="font-size:26px;font-weight:800;color:var(--aff);margin:8px 0">6.1%</div>
<div style="font-size:11px;color:var(--muted)">miss at 10% cache</div>
</div>
<div class="card" style="text-align:center">
<h3>Alpha 1.3</h3>
<div style="font-size:26px;font-weight:800;color:var(--lru);margin:8px 0">1.5%</div>
<div style="font-size:11px;color:var(--muted)">miss at 10% cache</div>
</div>
<div class="card" style="text-align:center">
<h3>Alpha 1.5</h3>
<div style="font-size:26px;font-weight:800;color:var(--part);margin:8px 0">0.6%</div>
<div style="font-size:11px;color:var(--muted)">miss at 10% cache</div>
</div>
</div>
</div>
<!-- ════════════════ LOCALITY ════════════════ -->
<div class="panel" id="panel-locality">
<div class="honest-box">
<strong>This is the v1.2 novel contribution:</strong> In v1.1, concurrency did not change locality structure. Now it does. CLIENT_AFFINITY creates N clients each with a private hot 5% key subset — merging their streams into a global arrival sequence expands the working set a shared LRU must cover. The charts below show how miss rate at a fixed cache size grows as client count increases, from 4.1% (1 client) to 27.2% (20 clients).
</div>
<div class="card full" style="margin-bottom:16px">
<h3>MRC by Client Count — Locality Degrades as Working Set Expands</h3>
<div class="chart-wrap" style="height:320px">
<canvas id="c-locality-mrc"></canvas>
</div>
<div class="insight">
<strong>The core insight:</strong> With 1 client, a 10% cache covers ~96% of requests. With 20 clients (each with disjoint hot keys), a global LRU at 10% covers only ~73%. Miss rate triples. This is why partitioned/affinity caches can be architecturally superior even at equal total cache size — they preserve per-client locality that a global LRU blurs away.
</div>
</div>
<div class="grid2">
<div class="card">
<h3>Miss Rate at 10% Cache vs Client Count</h3>
<div class="chart-wrap" style="height:260px">
<canvas id="c-locality-miss"></canvas>
</div>
<div class="insight" style="margin-top:12px">
Plateau at 50 clients (26.4%) is within simulation variance of 20 clients (27.2%). The effect saturates once disjoint hot subsets cover the available key space — a physically meaningful bound, not a model artifact.
</div>
</div>
<div class="card">
<h3>P95 by Configuration — 10K Concurrency, Alpha=1.3</h3>
<div class="chart-wrap" style="height:260px">
<canvas id="c-locality-p95"></canvas>
</div>
<div class="insight" style="margin-top:12px">
At equal total cache allocation, Partitioned achieves the best P95 because it eliminates shared-queue backend spikes. LRU has a similar hit rate but all misses funnel through one backend path.
</div>
</div>
</div>
<div class="section-label">MRC Shift Summary</div>
<div class="compare-row">
<div class="compare-card">
<div class="cfg-name">1 Client</div>
<div class="cfg-val" style="color:var(--part)">4.1%</div>
<div class="cfg-sub">miss at 10% cache</div>
</div>
<div class="compare-card">
<div class="cfg-name">5 Clients</div>
<div class="cfg-val" style="color:var(--lru)">12.0%</div>
<div class="cfg-sub">miss at 10% cache</div>
</div>
<div class="compare-card">
<div class="cfg-name">10 Clients</div>
<div class="cfg-val" style="color:var(--aff)">18.5%</div>
<div class="cfg-sub">miss at 10% cache</div>
</div>
<div class="compare-card">
<div class="cfg-name">20 Clients</div>
<div class="cfg-val" style="color:var(--no)">27.2%</div>
<div class="cfg-sub">miss at 10% cache · peak</div>
</div>
</div>
</div>
<!-- ════════════════ TABLE ════════════════ -->
<div class="panel" id="panel-table">
<div class="slider-wrap">
<label>Concurrency level:</label>
<input type="range" id="tblSlider" min="0" max="6" value="4" oninput="updateTable(this.value)">
<span class="slider-val" id="tblLabel">10,000 req/s</span>
</div>
<div class="card">
<h3>Full Results — 5 Trial Mean ± 95% Confidence Interval</h3>
<div class="table-scroll">
<table>
<thead>
<tr>
<th>Configuration</th>
<th>Concurrency</th>
<th>P50</th>
<th>P95 (mean ± CI)</th>
<th>P99 (est.)</th>
<th>Hit Rate</th>
<th>Backend Hit</th>
<th>Error Rate</th>
<th>Trials</th>
</tr>
</thead>
<tbody id="tbl-body"></tbody>
</table>
</div>
</div>
<div class="section-label">All Concurrency Levels — Quick Reference</div>
<div class="card">
<h3>P95 at Each Concurrency Level (ms) — Alpha = 1.3</h3>
<div class="chart-wrap" style="height:280px">
<canvas id="c-table-overview"></canvas>
</div>
</div>
</div>
<!-- ════════════════ TRACE VALIDATION ════════════════ -->
<div class="panel" id="panel-trace">
<!-- Two-cluster summary cards -->
<div style="display:grid; grid-template-columns:1fr 1fr; gap:16px;">
<div class="card" style="border-left:4px solid var(--warn); background:rgba(245,158,11,.07);">
<h3 style="color:var(--warn);">Cluster10 — Streaming Workload</h3>
<p style="color:var(--muted); font-size:12px; margin:8px 0 12px;">
α≈0.09. Oracle-trace analysis confirms extreme non-IRM behavior:
50% of requests are one-hit wonders and the median reuse distance spans the entire trace window.
No architecture helps — the workload is fundamentally uncacheable.
</p>
<div style="display:flex; gap:12px; flex-wrap:wrap;">
<div style="background:var(--surface2); border-radius:8px; padding:10px 16px; text-align:center;">
<div style="font-size:20px; font-weight:700; color:var(--warn);">50%</div>
<div style="font-size:10px; color:var(--muted);">One-hit wonders</div>
</div>
<div style="background:var(--surface2); border-radius:8px; padding:10px 16px; text-align:center;">
<div style="font-size:20px; font-weight:700; color:var(--no);">500K</div>
<div style="font-size:10px; color:var(--muted);">Median reuse distance</div>
</div>
<div style="background:var(--surface2); border-radius:8px; padding:10px 16px; text-align:center;">
<div style="font-size:20px; font-weight:700; color:var(--no);">0.06%</div>
<div style="font-size:10px; color:var(--muted);">Objects with ≥3 accesses</div>
</div>
<div style="background:var(--surface2); border-radius:8px; padding:10px 16px; text-align:center;">
<div style="font-size:20px; font-weight:700; color:var(--no);">~0%</div>
<div style="font-size:10px; color:var(--muted);">Hit rate (all configs)</div>
</div>
</div>
</div>
<div class="card" style="border-left:4px solid var(--accent2); background:rgba(52,211,153,.05);">
<h3 style="color:var(--accent2);">Cluster24 — High-Reuse Workload ✓</h3>
<p style="color:var(--muted); font-size:12px; margin:8px 0 12px;">
α≈1.585 (R²=0.986). 71 avg requests/key. Partitioned beats LRU on P95 by 24ms —
the synthetic prediction holds on real traces.
</p>
<div style="display:flex; gap:12px; flex-wrap:wrap;">
<div style="background:var(--surface2); border-radius:8px; padding:10px 16px; text-align:center;">
<div style="font-size:20px; font-weight:700; color:var(--accent2);">1.585</div>
<div style="font-size:10px; color:var(--muted);">Fitted α</div>
</div>
<div style="background:var(--surface2); border-radius:8px; padding:10px 16px; text-align:center;">
<div style="font-size:20px; font-weight:700; color:var(--accent2);">90.9%</div>
<div style="font-size:10px; color:var(--muted);">LRU + Partitioned hit rate</div>
</div>
<div style="background:var(--surface2); border-radius:8px; padding:10px 16px; text-align:center;">
<div style="font-size:20px; font-weight:700; color:var(--accent2);">156ms</div>
<div style="font-size:10px; color:var(--muted);">Partitioned P95</div>
</div>
</div>
</div>
</div>
<!-- Cluster24 charts -->
<div style="display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-top:16px;">
<div class="card">
<h3>Cluster24 — P95 Latency vs Synthetic (α=1.3) @ 10K</h3>
<p style="color:var(--muted); font-size:12px; margin:6px 0 12px;">
Partitioned wins P95 on real traces (156ms) vs LRU (180ms) — 13% improvement.
Same mechanism as synthetic: distributed queue pressure, not hit rate.
Client affinity collapses because 8,078 clients share only 1,393 cache slots.
</p>
<div style="height:240px; position:relative;">
<canvas id="c-trace-p95"></canvas>
</div>
</div>
<div class="card">
<h3>Cluster24 — Hit Rate vs Synthetic</h3>
<p style="color:var(--muted); font-size:12px; margin:6px 0 12px;">
LRU and Partitioned both hit 90.9% on real traces — above the synthetic 79.7%.
Client affinity collapses to 2.2% due to insufficient per-node capacity at real-world client counts.
This validates Yiyang's point: deployment constraints matter beyond just alpha.
</p>
<div style="height:240px; position:relative;">
<canvas id="c-trace-hitrate"></canvas>
</div>
</div>
</div>
<div class="card" style="margin-top:16px;">
<h3>MRC — Synthetic α curves vs Cluster10 (streaming) vs Cluster24 (high-reuse)</h3>
<p style="color:var(--muted); font-size:12px; margin:6px 0 12px;">
Cluster24 (green dashed) follows the synthetic α=1.5 curve closely — confirming the IRM model holds.
Cluster10 (orange dashed) stays flat at 100% — streaming workload, cache is useless regardless of size.
</p>
<div style="height:280px; position:relative;">
<canvas id="c-trace-mrc"></canvas>
</div>
</div>
<div class="card" style="margin-top:16px;">
<h3>Full Results — Twitter Cluster24 (high-reuse, α≈1.585)</h3>
<div class="table-scroll">
<table>
<thead><tr>
<th>Config</th><th>Hit Rate</th><th>P50 (ms)</th><th>P95 (ms)</th><th>P99 (ms)</th><th>Error Rate</th>
</tr></thead>
<tbody id="trace-table-body"></tbody>
</table>
</div>
<p style="color:var(--muted); font-size:11px; margin-top:10px;">
Source: Twitter twemcache cluster24 (100% sample). 500K GET/GETS operations. Latency model applied at concurrency=10,000.
The architecture differences in P95 here reflect queue routing, not cache hit rate.
</p>
</div>
<!-- Non-stochastic analysis section -->
<div class="card" style="margin-top:16px; border-left:4px solid #a78bfa; background:rgba(167,139,250,.05);">
<h3 style="color:#a78bfa;">Non-Stochastic Behavior Analysis — Cluster10 (Oracle Trace)</h3>
<p style="color:var(--muted); font-size:12px; margin:8px 0 14px;">
Analysis of the <code style="background:var(--surface3);padding:1px 5px;border-radius:4px;">oracleGeneral</code>
binary format, which includes <code style="background:var(--surface3);padding:1px 5px;border-radius:4px;">next_access_vtime</code> —
the virtual-time distance to the next access to the same object (<code>−1</code> = never accessed again).
This directly quantifies deviation from the IRM assumption underlying most caching theory.
</p>
<div style="display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:12px; margin-bottom:16px;">
<div style="background:var(--surface2); border-radius:8px; padding:12px 16px;">
<div style="font-size:24px; font-weight:700; color:#f87171;">50.0%</div>
<div style="font-size:11px; color:#a78bfa; font-weight:600; margin:2px 0;">One-hit wonders</div>
<div style="font-size:11px; color:var(--muted);">Requests to objects never seen again. Under IRM this would be ≈0%.</div>
</div>
<div style="background:var(--surface2); border-radius:8px; padding:12px 16px;">
<div style="font-size:24px; font-weight:700; color:#f87171;">500,009</div>
<div style="font-size:11px; color:#a78bfa; font-weight:600; margin:2px 0;">Median reuse distance</div>
<div style="font-size:11px; color:var(--muted);">P50 virtual-time gap between repeat accesses. Spans the full trace window.</div>
</div>
<div style="background:var(--surface2); border-radius:8px; padding:12px 16px;">
<div style="font-size:24px; font-weight:700; color:#f87171;">0.06%</div>
<div style="font-size:11px; color:#a78bfa; font-weight:600; margin:2px 0;">Objects with ≥3 accesses</div>
<div style="font-size:11px; color:var(--muted);">Almost no object is accessed frequently enough to warm the cache.</div>
</div>
<div style="background:var(--surface2); border-radius:8px; padding:12px 16px;">
<div style="font-size:24px; font-weight:700; color:#f87171;">0.002</div>
<div style="font-size:11px; color:#a78bfa; font-weight:600; margin:2px 0;">Oracle-trace Zipf α</div>
<div style="font-size:11px; color:var(--muted);">R²=0.034. Flat distribution — no Zipfian hot-spot structure whatsoever.</div>
</div>
<div style="background:var(--surface2); border-radius:8px; padding:12px 16px;">
<div style="font-size:24px; font-weight:700; color:#fb923c;">N/A</div>
<div style="font-size:11px; color:#a78bfa; font-weight:600; margin:2px 0;">IRM deviation (CoV)</div>
<div style="font-size:11px; color:var(--muted);">Undefined — 0 of 200 sampled objects had ≥3 accesses. Pure streaming.</div>
</div>
<div style="background:var(--surface2); border-radius:8px; padding:12px 16px;">
<div style="font-size:24px; font-weight:700; color:var(--accent2);">2.0×</div>
<div style="font-size:11px; color:#a78bfa; font-weight:600; margin:2px 0;">Avg requests / object</div>
<div style="font-size:11px; color:var(--muted);">500K unique objects in 1M requests. Almost every object seen exactly twice.</div>
</div>
</div>
<div style="background:var(--surface2); border-radius:8px; padding:14px 16px; border-left:3px solid #a78bfa;">
<div style="font-size:12px; font-weight:600; color:#a78bfa; margin-bottom:6px;">Why this matters for cache architecture</div>
<p style="font-size:12px; color:var(--muted); line-height:1.7;">
Standard caching theory (IRM, Zipf, stack-distance models) assumes a stationary popularity distribution
where objects have consistent access probability over time. Cluster10 violates all three:
half of all objects are never re-used, 99.94% are accessed fewer than 3 times, and the reuse
distance is indistinguishable from random. In this regime, <strong style="color:var(--text);">no
cache policy — LRU, CLOCK, or optimal — can achieve meaningful hit rates</strong>.
This is not a failure of the cache configuration; it is a workload property.
The practical implication: teams running streaming ingest pipelines should not rely on object caches
and should instead route requests directly, using the cache only for metadata.
</p>
</div>
</div>
</div>
<!-- ════════════════ CROSSOVER ANALYSIS ════════════════ -->
<div class="panel" id="panel-crossover">
<div class="card" style="border-left:4px solid var(--accent2); background:rgba(52,211,153,.04);">
<h3 style="color:var(--accent2);">The Real Crossover: Partitioned vs Client Affinity</h3>
<p style="color:var(--muted); font-size:12px; margin:8px 0 14px;">
Partitioned caching consistently beats shared LRU across <em>all</em> workloads — the advantage is
backend queue distribution, not hit rate. The interesting crossover is between
<strong style="color:var(--part);">Partitioned</strong> and
<strong style="color:var(--aff);">Client Affinity</strong>:
affinity helps at low α (no caching value, more nodes = less congestion),
but collapses above α≈0.8 once clients share popular keys and per-client slots become too small.
</p>
<div style="display:grid; grid-template-columns:repeat(4,1fr); gap:10px; margin-bottom:16px;">
<div id="xo-card-0" style="background:var(--surface2); border-radius:8px; padding:12px; text-align:center;"></div>
<div id="xo-card-1" style="background:var(--surface2); border-radius:8px; padding:12px; text-align:center;"></div>
<div id="xo-card-2" style="background:var(--surface2); border-radius:8px; padding:12px; text-align:center;"></div>
<div id="xo-card-3" style="background:var(--surface2); border-radius:8px; padding:12px; text-align:center;"></div>
</div>
</div>
<div style="display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-top:16px;">
<div class="card">
<h3>P95 vs Zipf α — All Configs (4 Twitter Clusters)</h3>
<p style="color:var(--muted); font-size:12px; margin:6px 0 12px;">
Client Affinity crosses over Partitioned between α=0.7 and α=1.1.
Below that it wins via node-count distribution; above it collapses due to key sharing.
</p>
<div style="height:280px; position:relative;">
<canvas id="c-crossover-p95"></canvas>
</div>
</div>
<div class="card">
<h3>Hit Rate vs Zipf α — LRU, Partitioned, Affinity</h3>
<p style="color:var(--muted); font-size:12px; margin:6px 0 12px;">
LRU and Partitioned track each other closely.
Client Affinity hit rate collapses above α≈0.8 as per-client capacity becomes insufficient.
</p>
<div style="height:280px; position:relative;">
<canvas id="c-crossover-hr"></canvas>
</div>
</div>
</div>
<div class="card" style="margin-top:16px;">
<h3>P95 Advantage of Partitioned over LRU (Δ ms) — Decreases as α rises</h3>
<p style="color:var(--muted); font-size:12px; margin:6px 0 12px;">
Counterintuitively, the Partitioned advantage is <em>largest at low α</em> (pure queue distribution)
and narrows as α grows (high hit rates reduce total backend pressure for both).
The P95 gap is never zero — Partitioned wins on queue routing alone.
</p>
<div style="height:200px; position:relative;">
<canvas id="c-crossover-delta"></canvas>
</div>
</div>
<!-- Prediction model -->
<div style="display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-top:16px;">
<div class="card">
<h3>Prediction Model: log(avg_req/obj) → P95 Gap</h3>
<p style="color:var(--muted); font-size:12px; margin:6px 0 12px;">
A single metric — average requests per unique object — predicts which architecture wins.
Linear fit on log scale: R²=0.977. Threshold: avg_req/obj ≈ 1.1.
No experiment needed — measure this from any access log.
</p>
<div style="height:240px; position:relative;">
<canvas id="c-predict-scatter"></canvas>
</div>
</div>
<div class="card" style="display:flex; flex-direction:column; gap:12px;">
<h3>Decision Rule — One Metric, One Answer</h3>
<div style="background:rgba(248,113,113,.08); border:1px solid rgba(248,113,113,.3);
border-radius:8px; padding:14px;">
<div style="font-size:11px; font-weight:700; color:#f87171; margin-bottom:6px; letter-spacing:.05em;">
IF avg_req/obj < 1.1
</div>
<div style="font-size:12px; color:var(--text); margin-bottom:4px;">
Streaming regime — architecture doesn't matter for cache efficiency
</div>
<div style="font-size:11px; color:var(--muted);">
Both Partitioned and Affinity achieve <10% hit rate.
Choose based on infrastructure simplicity, not cache theory.
</div>
</div>
<div style="background:rgba(52,211,153,.08); border:1px solid rgba(52,211,153,.3);
border-radius:8px; padding:14px;">
<div style="font-size:11px; font-weight:700; color:var(--accent2); margin-bottom:6px; letter-spacing:.05em;">
IF avg_req/obj ≥ 1.1
</div>
<div style="font-size:12px; color:var(--text); margin-bottom:4px;">
Reuse regime — use Partitioned over Client Affinity
</div>
<div style="font-size:11px; color:var(--muted);">
Per-client slots are insufficient when keys are shared across clients.
Partitioned routing prevents the hit-rate collapse of affinity.
</div>
</div>
<div style="background:var(--surface2); border-radius:8px; padding:12px; margin-top:auto;">
<div style="font-size:11px; color:var(--muted); margin-bottom:6px;">Predictor comparison vs Part-Affinity P95 gap (4 clusters)</div>
<div style="display:grid; grid-template-columns:1fr 1fr 1fr; gap:8px;">