Skip to content

Commit 15127f7

Browse files
[Autoloop: tsb-perf-evolve] Iteration 74: read _svCacheAL first for OOO speculation on hot path
Run: https://github.com/githubnext/tsb/actions/runs/27048758880 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent efd1417 commit 15127f7

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/core/series.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -780,18 +780,18 @@ export class Series<T extends Scalar = Scalar> {
780780

781781
/** Return a new Series sorted by values. */
782782
sortValues(ascending = true, naPosition: "first" | "last" = "last"): Series<T> {
783-
// ── Inline cache check: no method-call overhead on the hot path ──
784-
// AL=ascending+last, AF=ascending+first, DL=descending+last, DF=descending+first.
783+
// ── Hot path: read _svCacheAL unconditionally first so the CPU can overlap
784+
// the L1 cache load with branch-condition evaluation (OOO speculation).
785+
// AL=ascending+last (the default call), AF=ascending+first,
786+
// DL=descending+last, DF=descending+first.
787+
const al = this._svCacheAL;
788+
if (al !== null && ascending && naPosition === "last") return al;
785789
if (ascending) {
786-
const hit = naPosition === "last" ? this._svCacheAL : this._svCacheAF;
787-
if (hit !== null) {
788-
return hit;
789-
}
790+
const af = this._svCacheAF;
791+
if (af !== null) return af;
790792
} else {
791793
const hit = naPosition === "last" ? this._svCacheDL : this._svCacheDF;
792-
if (hit !== null) {
793-
return hit;
794-
}
794+
if (hit !== null) return hit;
795795
}
796796
const result = this._sortValuesColdPath(ascending, naPosition);
797797
this._svSetCache(ascending, naPosition, result);

0 commit comments

Comments
 (0)