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

   ### `putAtThreshold` slowdown: fix for the larger part (claim-first for 
single-page claims)
   
   **Change** (`AbstractFreeList.reserve()`, +9 −1): a single-page claim is 
added to `reservedPages` before the eviction and is admitted without a CAS. 
Multi-page claims keep the existing path (evict, then CAS, one accumulator at a 
time), because claims that do not fit the region together would wait for each 
other.
   
   ```java
   if (claimPages == 1) {
       reservedPages.incrementAndGet();
   
       accumulated = 1;
   }
   ```
   
   **Result.** Same setup as above (4 threads, threshold 0.95, 3 forks × 5 × 10 
s), all three builds measured in one session:
   
   | Build | Throughput, median (mean ± error), ops/ms | Time per op | Parked 
on page locks (JFR, 40 s × 4 threads) | Lock waits per op |
   |---|---|---|---|---|
   | branch before the change | 441.8 (420.2 ± 59.2) | 9.05 µs | 13 208 ms | 
0.206 |
   | **branch with the change** | **491.9 (491.0 ± 9.3)** | **8.13 µs** | **6 
880 ms** | **0.112** |
   | master | 523.5 (513.4 ± 31.3) | 7.64 µs | 2 251 ms | 0.048 |
   
   - **Slowdown vs master: ~15% → ~6%** in throughput (+18% → +6% in time per 
operation).
   - The change recovers **50 of the 82 ops/ms gap (61%)**, or 0.92 of 1.41 µs 
per operation.
   - Waiting on data-page locks drops by **48%**; the share of operations that 
hit a contended page lock roughly halves.
   - Region layout is unchanged (3–8 empty pages, `loaded` stops at threshold − 
pool).
   
   **What it says about the breakdown above**
   
   - The two branch builds differ only in the ordering for single-page claims: 
the eviction condition (`deficit`), the headroom term and the progress 
bookkeeping are identical. So the "rest of the original `reserve()` loop" 
bucket (~66%) is caused by the **evict-then-CAS ordering**; the bookkeeping and 
the headroom term are ruled out.
   - The result (491.0) matches the stripped-down claim-first build from the 
bisection (493.1).
   - The remaining ~6% matches the second bucket: evicting for other writers' 
in-flight claims (the `reserved` term in `deficit`). It is not addressed by 
this change and was not re-measured in this session.
   
   **Guarantees**
   
   - Not changed: the eviction condition, the no-progress guard, the stall 
logic and the multi-page path. A single-page claim is released on every refusal 
path by the existing `finally`.
   - One visible difference: `reservedPages` now also counts single-page claims 
that still wait for the eviction, so waiting writers see each other.
   


-- 
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