wernerdv commented on PR #13554:
URL: https://github.com/apache/ignite/pull/13554#issuecomment-6816229323

   ### `putAtThreshold` slowdown: breakdown
   
   **Setup:** `JmhPageEvictionBenchmark.putAtThreshold`, 4 threads, threshold 
0.95 on both sides, 3 forks × 5 × 10 s, JDK 17. Branch vs `master` (merge-base 
`b0c397908d0`). Time per operation = 4 / throughput, per writer thread.
   
   **Overall:** the branch is **~15% slower** in throughput, **+1.36 µs per 
operation (+17.8%)**. With **1 thread** there is no slowdown (160.3 vs 157.3 
ops/ms), so it is entirely concurrency-related.
   
   | Build | Throughput, ops/ms | Time per op | Parked on page locks (JFR, 40 s 
× 4 threads) |
   |---|---|---|---|
   | master (two runs) | 511.2 ± 13.4 / 534.2 ± 15.6 | 7.49–7.82 µs | 3 385 ms |
   | branch, master's eviction trigger + shared counters (baseline) | 523.3 ± 
9.2 | 7.64 µs | 2 685 ms |
   | … + evicting for in-flight claims | 493.1 ± 3.9 | 8.11 µs | 7 783 ms |
   | **branch as is** | **444.3 ± 6.9** | **9.00 µs** | **13 849 ms** |
   
   #### Breakdown
   
   | Cause | Per-op slowdown | Share | Throughput lost | Extra lock waiting |
   |---|---|---|---|---|
   | Rest of the original `reserve()` loop: evict-then-CAS ordering, `deficit` 
recomputed after each eviction and failed CAS, headroom term `max(0, limit − 
loaded)`, progress bookkeeping (not split further) | **+0.89 µs** | **~66%** | 
−48.8 ops/ms | +6.1 s (54%) |
   | Evicting for other writers' in-flight claims (`reserved` term in 
`deficit`, one page per claim held for the whole update) | **+0.47 µs** | 
**~34%** | −30.2 ops/ms | +5.1 s (46%) |
   | Shared atomic counters (`reservedPages` CAS + release, `evictedCnt`) | ≈ 0 
| 0% (noise) | — | — |
   | Everything outside `reserve()` (`reserveBatchSpace`, `rowSize`, 
`releaseInRegion`) | ≈ 0 | 0% (noise) | — | ≈ 0 |
   | Empty-page buffer / region layout (pool kept as headroom instead of empty 
pages) | ≈ 0 | 0% | — | ≈ 0 |
   | Eviction CPU, eviction placement in the put path, victim selection, row 
reads | ≈ 0 | 0% | — | — |
   | Synchronized eviction bursts | — | 0% | — | — |
   
   #### How it was established
   
   - **Bisection inside `reserve()`:** swapping only its body for master's 
trigger (`while (loaded > threshold && empty < pool) evict`) restores master 
throughput (514.2) and master lock waiting (3 373 ms). Adding back the counter 
traffic stays fast (523.3). Adding the in-flight-claims condition costs ~34%.
   - **JFR:** CPU per operation and the eviction share (39–41%) are the same on 
both sides. The difference is waiting on data-page locks: B+tree key 
comparison, row insert, row removal, fragment reads.
   - **Ruled out:**
     - Layout: a variant keeping ~100 empty pages, like master, is as slow as 
the branch (434.4).
     - Eviction placement: both evict before `lockEntries` (code reading).
     - Synchronized eviction: writers evict independently, with a sample 
clustering ratio of 0.97–1.03 in every build.
   
   #### Caveats
   
   - The two master runs differ by ~4% (511 vs 534); differences under ~20 
ops/ms are noise.
   - One session of 3 forks per build. The shares are computed against the 
counters build as the baseline.
   - The ~66% "rest of the loop" bucket is not split further yet. The next step 
is the original loop without the `reserved` term.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to