[libcxx-commits] [libcxx] [libcxx] Allow configuration of deque block size (PR #198348)

Prabhu Rajasekaran via libcxx-commits libcxx-commits at lists.llvm.org
Tue May 19 13:00:27 PDT 2026


https://github.com/Prabhuk updated https://github.com/llvm/llvm-project/pull/198348

>From 741b83a0dc3ca2307bf7a1ccbc77eb8355c79aa6 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Mon, 18 May 2026 10:24:58 -0700
Subject: [PATCH 1/6] [libcxx] Allow configuration of deque block size

Larger block size for deque is unsuitable for several environments with
severe memory pressures. Provide configuration option for lower deque
block size.

Please note the test files are generated using an LLM.
---
 libcxx/include/__cxx03/deque                  |  4 +++
 libcxx/include/deque                          |  4 +++
 ..._deque_block_size.default.compile.pass.cpp | 31 +++++++++++++++++
 ...er_deque_block_size.lower.compile.pass.cpp | 33 +++++++++++++++++++
 4 files changed, 72 insertions(+)
 create mode 100644 libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.default.compile.pass.cpp
 create mode 100644 libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.lower.compile.pass.cpp

diff --git a/libcxx/include/__cxx03/deque b/libcxx/include/__cxx03/deque
index 22b02af4ad60de..ade460d0ba2f21 100644
--- a/libcxx/include/__cxx03/deque
+++ b/libcxx/include/__cxx03/deque
@@ -232,7 +232,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _ValueType, class _DiffType>
 struct __deque_block_size {
+#ifdef _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
+  static const _DiffType value = sizeof(_ValueType) < 256 ? 512 / sizeof(_ValueType) : 2;
+#else
   static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16;
+#endif
 };
 
 template <class _ValueType,
diff --git a/libcxx/include/deque b/libcxx/include/deque
index c8c6889f1a1659..0a94e2cf163cc3 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -265,7 +265,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _ValueType, class _DiffType>
 struct __deque_block_size {
+#ifdef _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
+  static const _DiffType value = sizeof(_ValueType) < 256 ? 512 / sizeof(_ValueType) : 2;
+#else
   static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16;
+#endif
 };
 
 template <class _ValueType,
diff --git a/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.default.compile.pass.cpp b/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.default.compile.pass.cpp
new file mode 100644
index 00000000000000..7803ffab38718c
--- /dev/null
+++ b/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.default.compile.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Test that std::__deque_block_size has default sizes when _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE is not defined.
+
+#include <deque>
+#include <cstddef>
+
+template <std::size_t Size>
+struct TypeOfSize {
+  char data[Size];
+};
+
+static_assert(std::__deque_block_size<char, std::ptrdiff_t>::value == 4096, "");
+static_assert(std::__deque_block_size<int, std::ptrdiff_t>::value == 1024, "");
+static_assert(std::__deque_block_size<double, std::ptrdiff_t>::value == 512, "");
+
+static_assert(std::__deque_block_size<TypeOfSize<255>, std::ptrdiff_t>::value == 16, "");
+static_assert(std::__deque_block_size<TypeOfSize<256>, std::ptrdiff_t>::value == 16, "");
+static_assert(std::__deque_block_size<TypeOfSize<512>, std::ptrdiff_t>::value == 16, "");
+
+int main(int, char**) {
+  return 0;
+}
diff --git a/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.lower.compile.pass.cpp b/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.lower.compile.pass.cpp
new file mode 100644
index 00000000000000..b69bdccf8fb710
--- /dev/null
+++ b/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.lower.compile.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Test that std::__deque_block_size has lowered sizes when _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE is defined.
+
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
+
+#include <deque>
+#include <cstddef>
+
+template <std::size_t Size>
+struct TypeOfSize {
+  char data[Size];
+};
+
+static_assert(std::__deque_block_size<char, std::ptrdiff_t>::value == 512, "");
+static_assert(std::__deque_block_size<int, std::ptrdiff_t>::value == 128, "");
+static_assert(std::__deque_block_size<double, std::ptrdiff_t>::value == 64, "");
+
+static_assert(std::__deque_block_size<TypeOfSize<255>, std::ptrdiff_t>::value == 2, "");
+static_assert(std::__deque_block_size<TypeOfSize<256>, std::ptrdiff_t>::value == 2, "");
+static_assert(std::__deque_block_size<TypeOfSize<512>, std::ptrdiff_t>::value == 2, "");
+
+int main(int, char**) {
+  return 0;
+}

>From 88aa39f31c3951949519329b18d93f5744c3b70f Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Mon, 18 May 2026 10:32:20 -0700
Subject: [PATCH 2/6] format

---
 .../deque/lower_deque_block_size.default.compile.pass.cpp     | 4 +---
 .../deque/lower_deque_block_size.lower.compile.pass.cpp       | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.default.compile.pass.cpp b/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.default.compile.pass.cpp
index 7803ffab38718c..f0568ead207da2 100644
--- a/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.default.compile.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.default.compile.pass.cpp
@@ -26,6 +26,4 @@ static_assert(std::__deque_block_size<TypeOfSize<255>, std::ptrdiff_t>::value ==
 static_assert(std::__deque_block_size<TypeOfSize<256>, std::ptrdiff_t>::value == 16, "");
 static_assert(std::__deque_block_size<TypeOfSize<512>, std::ptrdiff_t>::value == 16, "");
 
-int main(int, char**) {
-  return 0;
-}
+int main(int, char**) { return 0; }
diff --git a/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.lower.compile.pass.cpp b/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.lower.compile.pass.cpp
index b69bdccf8fb710..07a575bb0a5138 100644
--- a/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.lower.compile.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.lower.compile.pass.cpp
@@ -28,6 +28,4 @@ static_assert(std::__deque_block_size<TypeOfSize<255>, std::ptrdiff_t>::value ==
 static_assert(std::__deque_block_size<TypeOfSize<256>, std::ptrdiff_t>::value == 2, "");
 static_assert(std::__deque_block_size<TypeOfSize<512>, std::ptrdiff_t>::value == 2, "");
 
-int main(int, char**) {
-  return 0;
-}
+int main(int, char**) { return 0; }

>From b9655d4c44715df739afe6709d86cc50864756bb Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Mon, 18 May 2026 19:44:58 -0700
Subject: [PATCH 3/6] make the calculation generic.

---
 libcxx/include/__cxx03/deque | 7 ++++++-
 libcxx/include/deque         | 7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/__cxx03/deque b/libcxx/include/__cxx03/deque
index ade460d0ba2f21..7dd923e3605dce 100644
--- a/libcxx/include/__cxx03/deque
+++ b/libcxx/include/__cxx03/deque
@@ -233,7 +233,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 template <class _ValueType, class _DiffType>
 struct __deque_block_size {
 #ifdef _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
-  static const _DiffType value = sizeof(_ValueType) < 256 ? 512 / sizeof(_ValueType) : 2;
+  static constexpr _DiffType kTargetBlockSizeBytes = 512;
+  static constexpr _DiffType kMinElementsPerBlock = 2;
+  
+  static const _DiffType value = (sizeof(_ValueType) * kMinElementsPerBlock < kTargetBlockSizeBytes) 
+      ? (kTargetBlockSizeBytes / sizeof(_ValueType)) 
+      : kMinElementsPerBlock;
 #else
   static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16;
 #endif
diff --git a/libcxx/include/deque b/libcxx/include/deque
index 0a94e2cf163cc3..139702115d64d1 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -266,7 +266,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 template <class _ValueType, class _DiffType>
 struct __deque_block_size {
 #ifdef _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
-  static const _DiffType value = sizeof(_ValueType) < 256 ? 512 / sizeof(_ValueType) : 2;
+  static constexpr _DiffType kTargetBlockSizeBytes = 512;
+  static constexpr _DiffType kMinElementsPerBlock = 2;
+  
+  static const _DiffType value = (sizeof(_ValueType) * kMinElementsPerBlock < kTargetBlockSizeBytes) 
+      ? (kTargetBlockSizeBytes / sizeof(_ValueType)) 
+      : kMinElementsPerBlock;
 #else
   static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16;
 #endif

>From 2055a1623362b7d11ccf0199e80f5c3c7be2a4c4 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Tue, 19 May 2026 10:08:28 -0700
Subject: [PATCH 4/6] Add default to __config and use const instead of
 constexpr

---
 libcxx/include/__config                                     | 4 ++++
 libcxx/include/__cxx03/__config                             | 4 ++++
 libcxx/include/__cxx03/deque                                | 6 +++---
 libcxx/include/deque                                        | 6 +++---
 .../deque/lower_deque_block_size.default.compile.pass.cpp   | 2 ++
 .../deque/lower_deque_block_size.lower.compile.pass.cpp     | 6 ++++--
 6 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/libcxx/include/__config b/libcxx/include/__config
index a34c6ee502bb24..ef8d167ed368b2 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -522,6 +522,10 @@ typedef __char32_t char32_t;
 
 #  define _PSTL_USE_NONTEMPORAL_STORES_IF_ALLOWED
 
+#  ifndef _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
+#    define _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE 0
+#  endif
+
 #endif // __cplusplus
 
 #endif // _LIBCPP___CONFIG
diff --git a/libcxx/include/__cxx03/__config b/libcxx/include/__cxx03/__config
index d955429cc4ddc0..c12e8b4e6b33c3 100644
--- a/libcxx/include/__cxx03/__config
+++ b/libcxx/include/__cxx03/__config
@@ -1072,6 +1072,10 @@ typedef __char32_t char32_t;
 #    define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
 #  endif
 
+#  ifndef _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
+#    define _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE 0
+#  endif
+
 #endif // __cplusplus
 
 #endif // _LIBCPP___CXX03___CONFIG
diff --git a/libcxx/include/__cxx03/deque b/libcxx/include/__cxx03/deque
index 7dd923e3605dce..3df0209ea68238 100644
--- a/libcxx/include/__cxx03/deque
+++ b/libcxx/include/__cxx03/deque
@@ -232,9 +232,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _ValueType, class _DiffType>
 struct __deque_block_size {
-#ifdef _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
-  static constexpr _DiffType kTargetBlockSizeBytes = 512;
-  static constexpr _DiffType kMinElementsPerBlock = 2;
+#if _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
+  static const _DiffType kTargetBlockSizeBytes = 512;
+  static const _DiffType kMinElementsPerBlock = 2;
   
   static const _DiffType value = (sizeof(_ValueType) * kMinElementsPerBlock < kTargetBlockSizeBytes) 
       ? (kTargetBlockSizeBytes / sizeof(_ValueType)) 
diff --git a/libcxx/include/deque b/libcxx/include/deque
index 139702115d64d1..509b4d7ce4bc3d 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -265,9 +265,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _ValueType, class _DiffType>
 struct __deque_block_size {
-#ifdef _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
-  static constexpr _DiffType kTargetBlockSizeBytes = 512;
-  static constexpr _DiffType kMinElementsPerBlock = 2;
+#if _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
+  static const _DiffType kTargetBlockSizeBytes = 512;
+  static const _DiffType kMinElementsPerBlock = 2;
   
   static const _DiffType value = (sizeof(_ValueType) * kMinElementsPerBlock < kTargetBlockSizeBytes) 
       ? (kTargetBlockSizeBytes / sizeof(_ValueType)) 
diff --git a/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.default.compile.pass.cpp b/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.default.compile.pass.cpp
index f0568ead207da2..e539741a33b422 100644
--- a/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.default.compile.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.default.compile.pass.cpp
@@ -18,6 +18,8 @@ struct TypeOfSize {
   char data[Size];
 };
 
+static_assert(_LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE == 0, "");
+
 static_assert(std::__deque_block_size<char, std::ptrdiff_t>::value == 4096, "");
 static_assert(std::__deque_block_size<int, std::ptrdiff_t>::value == 1024, "");
 static_assert(std::__deque_block_size<double, std::ptrdiff_t>::value == 512, "");
diff --git a/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.lower.compile.pass.cpp b/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.lower.compile.pass.cpp
index 07a575bb0a5138..b29143ba85d5ee 100644
--- a/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.lower.compile.pass.cpp
+++ b/libcxx/test/libcxx/containers/sequences/deque/lower_deque_block_size.lower.compile.pass.cpp
@@ -8,9 +8,9 @@
 
 // <deque>
 
-// Test that std::__deque_block_size has lowered sizes when _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE is defined.
+// Test that std::__deque_block_size has lowered sizes when _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE is defined to 1.
 
-// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE=1
 
 #include <deque>
 #include <cstddef>
@@ -20,6 +20,8 @@ struct TypeOfSize {
   char data[Size];
 };
 
+static_assert(_LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE == 1, "");
+
 static_assert(std::__deque_block_size<char, std::ptrdiff_t>::value == 512, "");
 static_assert(std::__deque_block_size<int, std::ptrdiff_t>::value == 128, "");
 static_assert(std::__deque_block_size<double, std::ptrdiff_t>::value == 64, "");

>From bd2df696ded2c4abcbd0429fe1f4c7732129d4f7 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Tue, 19 May 2026 10:25:11 -0700
Subject: [PATCH 5/6] Format

---
 libcxx/include/__cxx03/deque | 4 ++--
 libcxx/include/deque         | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/libcxx/include/__cxx03/deque b/libcxx/include/__cxx03/deque
index 3df0209ea68238..cff50d7eba5d26 100644
--- a/libcxx/include/__cxx03/deque
+++ b/libcxx/include/__cxx03/deque
@@ -234,8 +234,8 @@ template <class _ValueType, class _DiffType>
 struct __deque_block_size {
 #if _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
   static const _DiffType kTargetBlockSizeBytes = 512;
-  static const _DiffType kMinElementsPerBlock = 2;
-  
+  static const _DiffType kMinElementsPerBlock  = 2;
+
   static const _DiffType value = (sizeof(_ValueType) * kMinElementsPerBlock < kTargetBlockSizeBytes) 
       ? (kTargetBlockSizeBytes / sizeof(_ValueType)) 
       : kMinElementsPerBlock;
diff --git a/libcxx/include/deque b/libcxx/include/deque
index 509b4d7ce4bc3d..f488c20d8739d0 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -267,14 +267,14 @@ template <class _ValueType, class _DiffType>
 struct __deque_block_size {
 #if _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
   static const _DiffType kTargetBlockSizeBytes = 512;
-  static const _DiffType kMinElementsPerBlock = 2;
-  
+  static const _DiffType kMinElementsPerBlock  = 2;
+
   static const _DiffType value = (sizeof(_ValueType) * kMinElementsPerBlock < kTargetBlockSizeBytes) 
       ? (kTargetBlockSizeBytes / sizeof(_ValueType)) 
       : kMinElementsPerBlock;
 #else
   static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16;
-#endif
+#  endif
 };
 
 template <class _ValueType,

>From 0891a3092d5c001dfdb13a1197a7326e1e118b1c Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Tue, 19 May 2026 12:46:03 -0700
Subject: [PATCH 6/6] define default block size macro

---
 libcxx/include/__config         |  5 +++++
 libcxx/include/__cxx03/__config |  5 +++++
 libcxx/include/__cxx03/deque    | 14 ++++----------
 libcxx/include/deque            | 14 ++++----------
 4 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/libcxx/include/__config b/libcxx/include/__config
index ef8d167ed368b2..d7e010a604208e 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -524,6 +524,11 @@ typedef __char32_t char32_t;
 
 #  ifndef _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
 #    define _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE 0
+#    define _LIBCPP_DEQUE_TARGET_BLOCK_SIZE 4096
+#    define _LIBCPP_DEQUE_MIN_ELEMENTS_PER_BLOCK 16
+#  else
+#    define _LIBCPP_DEQUE_TARGET_BLOCK_SIZE 512
+#    define _LIBCPP_DEQUE_MIN_ELEMENTS_PER_BLOCK 2
 #  endif
 
 #endif // __cplusplus
diff --git a/libcxx/include/__cxx03/__config b/libcxx/include/__cxx03/__config
index c12e8b4e6b33c3..93c0e6d39ac6df 100644
--- a/libcxx/include/__cxx03/__config
+++ b/libcxx/include/__cxx03/__config
@@ -1074,6 +1074,11 @@ typedef __char32_t char32_t;
 
 #  ifndef _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
 #    define _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE 0
+#    define _LIBCPP_DEQUE_TARGET_BLOCK_SIZE 4096
+#    define _LIBCPP_DEQUE_MIN_ELEMENTS_PER_BLOCK 16
+#  else
+#    define _LIBCPP_DEQUE_TARGET_BLOCK_SIZE 512
+#    define _LIBCPP_DEQUE_MIN_ELEMENTS_PER_BLOCK 2
 #  endif
 
 #endif // __cplusplus
diff --git a/libcxx/include/__cxx03/deque b/libcxx/include/__cxx03/deque
index cff50d7eba5d26..b860723cbc5cad 100644
--- a/libcxx/include/__cxx03/deque
+++ b/libcxx/include/__cxx03/deque
@@ -232,16 +232,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _ValueType, class _DiffType>
 struct __deque_block_size {
-#if _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
-  static const _DiffType kTargetBlockSizeBytes = 512;
-  static const _DiffType kMinElementsPerBlock  = 2;
-
-  static const _DiffType value = (sizeof(_ValueType) * kMinElementsPerBlock < kTargetBlockSizeBytes) 
-      ? (kTargetBlockSizeBytes / sizeof(_ValueType)) 
-      : kMinElementsPerBlock;
-#else
-  static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16;
-#endif
+  static const _DiffType value =
+      (sizeof(_ValueType) * _LIBCPP_DEQUE_MIN_ELEMENTS_PER_BLOCK < _LIBCPP_DEQUE_TARGET_BLOCK_SIZE)
+          ? (_LIBCPP_DEQUE_TARGET_BLOCK_SIZE / sizeof(_ValueType))
+          : _LIBCPP_DEQUE_MIN_ELEMENTS_PER_BLOCK;
 };
 
 template <class _ValueType,
diff --git a/libcxx/include/deque b/libcxx/include/deque
index f488c20d8739d0..8cce1f5069b2eb 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -265,16 +265,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 template <class _ValueType, class _DiffType>
 struct __deque_block_size {
-#if _LIBCPP_USE_LOWER_DEQUE_BLOCK_SIZE
-  static const _DiffType kTargetBlockSizeBytes = 512;
-  static const _DiffType kMinElementsPerBlock  = 2;
-
-  static const _DiffType value = (sizeof(_ValueType) * kMinElementsPerBlock < kTargetBlockSizeBytes) 
-      ? (kTargetBlockSizeBytes / sizeof(_ValueType)) 
-      : kMinElementsPerBlock;
-#else
-  static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16;
-#  endif
+  static const _DiffType value =
+      (sizeof(_ValueType) * _LIBCPP_DEQUE_MIN_ELEMENTS_PER_BLOCK < _LIBCPP_DEQUE_TARGET_BLOCK_SIZE)
+          ? (_LIBCPP_DEQUE_TARGET_BLOCK_SIZE / sizeof(_ValueType))
+          : _LIBCPP_DEQUE_MIN_ELEMENTS_PER_BLOCK;
 };
 
 template <class _ValueType,



More information about the libcxx-commits mailing list