Skip to content

Commit ab41b71

Browse files
committed
perf: cache static identifiers to avoid per-call interner locks
`id()` methods interned their `Id` via `Id::new`/`Id::new_static` on every call, locking the global interner on hot paths. Use a `CachedId` static that interns once and returns the cached `Id` lock-free; same value. Refs: #8380 Signed-off-by: Han Damin <miniex@daminstudio.net>
1 parent bf2be52 commit ab41b71

37 files changed

Lines changed: 110 additions & 38 deletions

File tree

vortex-array/src/aggregate_fn/fns/all_nan/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use vortex_error::VortexResult;
55
use vortex_session::VortexSession;
6+
use vortex_session::registry::CachedId;
67

78
use crate::ArrayRef;
89
use crate::Columnar;
@@ -34,7 +35,8 @@ impl AggregateFnVTable for AllNan {
3435
type Partial = bool;
3536

3637
fn id(&self) -> AggregateFnId {
37-
AggregateFnId::new("vortex.all_nan")
38+
static ID: CachedId = CachedId::new("vortex.all_nan");
39+
*ID
3840
}
3941

4042
fn serialize(&self, _options: &Self::Options) -> VortexResult<Option<Vec<u8>>> {

vortex-array/src/aggregate_fn/fns/all_non_distinct/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use std::sync::LazyLock;
1919
use vortex_error::VortexResult;
2020
use vortex_error::vortex_bail;
2121
use vortex_error::vortex_err;
22+
use vortex_session::registry::CachedId;
2223

2324
use self::bool::check_bool_identical;
2425
use self::decimal::check_decimal_identical;
@@ -121,7 +122,8 @@ impl AggregateFnVTable for AllNonDistinct {
121122
type Partial = AllNonDistinctPartial;
122123

123124
fn id(&self) -> AggregateFnId {
124-
AggregateFnId::new("vortex.all_non_distinct")
125+
static ID: CachedId = CachedId::new("vortex.all_non_distinct");
126+
*ID
125127
}
126128

127129
fn serialize(&self, _options: &Self::Options) -> VortexResult<Option<Vec<u8>>> {

vortex-array/src/aggregate_fn/fns/all_non_nan/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use vortex_error::VortexResult;
55
use vortex_session::VortexSession;
6+
use vortex_session::registry::CachedId;
67

78
use crate::ArrayRef;
89
use crate::Columnar;
@@ -34,7 +35,8 @@ impl AggregateFnVTable for AllNonNan {
3435
type Partial = bool;
3536

3637
fn id(&self) -> AggregateFnId {
37-
AggregateFnId::new("vortex.all_non_nan")
38+
static ID: CachedId = CachedId::new("vortex.all_non_nan");
39+
*ID
3840
}
3941

4042
fn serialize(&self, _options: &Self::Options) -> VortexResult<Option<Vec<u8>>> {

vortex-array/src/aggregate_fn/fns/all_non_null/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use vortex_error::VortexResult;
55
use vortex_session::VortexSession;
6+
use vortex_session::registry::CachedId;
67

78
use crate::ArrayRef;
89
use crate::Columnar;
@@ -26,7 +27,8 @@ impl AggregateFnVTable for AllNonNull {
2627
type Partial = bool;
2728

2829
fn id(&self) -> AggregateFnId {
29-
AggregateFnId::new("vortex.all_non_null")
30+
static ID: CachedId = CachedId::new("vortex.all_non_null");
31+
*ID
3032
}
3133

3234
fn serialize(&self, _options: &Self::Options) -> VortexResult<Option<Vec<u8>>> {

vortex-array/src/aggregate_fn/fns/all_null/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use vortex_error::VortexResult;
55
use vortex_session::VortexSession;
6+
use vortex_session::registry::CachedId;
67

78
use crate::ArrayRef;
89
use crate::Columnar;
@@ -26,7 +27,8 @@ impl AggregateFnVTable for AllNull {
2627
type Partial = bool;
2728

2829
fn id(&self) -> AggregateFnId {
29-
AggregateFnId::new("vortex.all_null")
30+
static ID: CachedId = CachedId::new("vortex.all_null");
31+
*ID
3032
}
3133

3234
fn serialize(&self, _options: &Self::Options) -> VortexResult<Option<Vec<u8>>> {

vortex-array/src/aggregate_fn/fns/bounded_max/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use vortex_error::VortexResult;
1313
use vortex_error::vortex_bail;
1414
use vortex_error::vortex_ensure;
1515
use vortex_session::VortexSession;
16+
use vortex_session::registry::CachedId;
1617

1718
use crate::ArrayRef;
1819
use crate::Columnar;
@@ -125,7 +126,8 @@ impl AggregateFnVTable for BoundedMax {
125126
type Partial = BoundedMaxPartial;
126127

127128
fn id(&self) -> AggregateFnId {
128-
AggregateFnId::new("vortex.bounded_max")
129+
static ID: CachedId = CachedId::new("vortex.bounded_max");
130+
*ID
129131
}
130132

131133
fn serialize(&self, options: &Self::Options) -> VortexResult<Option<Vec<u8>>> {

vortex-array/src/aggregate_fn/fns/bounded_min/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use vortex_error::VortexExpect;
1111
use vortex_error::VortexResult;
1212
use vortex_error::vortex_ensure;
1313
use vortex_session::VortexSession;
14+
use vortex_session::registry::CachedId;
1415

1516
use crate::ArrayRef;
1617
use crate::Columnar;
@@ -79,7 +80,8 @@ impl AggregateFnVTable for BoundedMin {
7980
type Partial = BoundedMinPartial;
8081

8182
fn id(&self) -> AggregateFnId {
82-
AggregateFnId::new("vortex.bounded_min")
83+
static ID: CachedId = CachedId::new("vortex.bounded_min");
84+
*ID
8385
}
8486

8587
fn serialize(&self, options: &Self::Options) -> VortexResult<Option<Vec<u8>>> {

vortex-array/src/aggregate_fn/fns/count/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ mod grouped;
55
pub(crate) use grouped::CountGroupedKernel;
66
use vortex_error::VortexExpect;
77
use vortex_error::VortexResult;
8+
use vortex_session::registry::CachedId;
89

910
use crate::ArrayRef;
1011
use crate::Columnar;
@@ -41,7 +42,8 @@ impl AggregateFnVTable for Count {
4142
type Partial = CountPartial;
4243

4344
fn id(&self) -> AggregateFnId {
44-
AggregateFnId::new("vortex.count")
45+
static ID: CachedId = CachedId::new("vortex.count");
46+
*ID
4547
}
4648

4749
fn serialize(&self, _options: &Self::Options) -> VortexResult<Option<Vec<u8>>> {

vortex-array/src/aggregate_fn/fns/first/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// SPDX-FileCopyrightText: Copyright the Vortex contributors
33

44
use vortex_error::VortexResult;
5+
use vortex_session::registry::CachedId;
56

67
use crate::ArrayRef;
78
use crate::Columnar;
@@ -40,7 +41,8 @@ impl AggregateFnVTable for First {
4041
type Partial = FirstPartial;
4142

4243
fn id(&self) -> AggregateFnId {
43-
AggregateFnId::new("vortex.first")
44+
static ID: CachedId = CachedId::new("vortex.first");
45+
*ID
4446
}
4547

4648
fn serialize(&self, _options: &Self::Options) -> VortexResult<Option<Vec<u8>>> {

vortex-array/src/aggregate_fn/fns/is_constant/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ mod varbin;
1313
use vortex_error::VortexExpect;
1414
use vortex_error::VortexResult;
1515
use vortex_error::vortex_bail;
16+
use vortex_session::registry::CachedId;
1617

1718
use self::bool::check_bool_constant;
1819
use self::decimal::check_decimal_constant;
@@ -258,7 +259,8 @@ impl AggregateFnVTable for IsConstant {
258259
type Partial = IsConstantPartial;
259260

260261
fn id(&self) -> AggregateFnId {
261-
AggregateFnId::new("vortex.is_constant")
262+
static ID: CachedId = CachedId::new("vortex.is_constant");
263+
*ID
262264
}
263265

264266
fn serialize(&self, _options: &Self::Options) -> VortexResult<Option<Vec<u8>>> {

0 commit comments

Comments
 (0)