Use Layout::WithStaticSizes in SerialArenaChunk to improve performance of Layout computations.

PiperOrigin-RevId: 688155852
pull/18892/head
Evan Brown 5 months ago committed by Copybara-Service
parent ba85b2003f
commit f971ed3f36
  1. 6
      .github/workflows/test_cpp.yml
  2. 2
      protobuf_deps.bzl
  3. 5
      src/google/protobuf/arena.cc

@ -173,7 +173,7 @@ jobs:
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
uses: protocolbuffers/protobuf-ci/docker@v3
with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.16.9-f39fc8b4e244fe5cd4c7138d0b6959a52b46ca48
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.16.9-d9624f2aa83cba3eaf906f751d75b36aacb9aa82
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: >-
/test.sh ${{ matrix.flags}} ${{ env.SCCACHE_CMAKE_FLAGS }}
@ -212,7 +212,7 @@ jobs:
uses: protocolbuffers/protobuf-ci/docker@v3
if: ${{ !matrix.continuous-only || inputs.continuous-run }}
with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.16.9-f39fc8b4e244fe5cd4c7138d0b6959a52b46ca48
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.16.9-d9624f2aa83cba3eaf906f751d75b36aacb9aa82
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: >-
/install.sh -DCMAKE_CXX_STANDARD=17 ${{ env.SCCACHE_CMAKE_FLAGS }}
@ -248,7 +248,7 @@ jobs:
if: ${{ inputs.continuous-run }}
uses: protocolbuffers/protobuf-ci/docker@v3
with:
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.16.9-f39fc8b4e244fe5cd4c7138d0b6959a52b46ca48
image: us-docker.pkg.dev/protobuf-build/containers/test/linux/cmake:3.16.9-d9624f2aa83cba3eaf906f751d75b36aacb9aa82
credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }}
command: >-
/install.sh -DCMAKE_CXX_STANDARD=17 ${{ env.SCCACHE_CMAKE_FLAGS }}

@ -62,8 +62,6 @@ def protobuf_deps():
_github_archive(
name = "com_google_absl",
repo = "https://github.com/abseil/abseil-cpp",
# TODO: use Layout::WithStaticSizes in SerialArenaChunk when we update
# abseil to new release.
commit = "4447c7562e3bc702ade25105912dce503f0c4010", # Abseil LTS 20240722.0
sha256 = "d8342ad77aa9e16103c486b615460c24a695a1f04cdb760eb02fef780df99759",
)

@ -507,7 +507,8 @@ class ThreadSafeArena::SerialArenaChunk {
constexpr static int kArenas = 2;
using layout_type = absl::container_internal::Layout<
SerialArenaChunkHeader, std::atomic<void*>, std::atomic<SerialArena*>>;
SerialArenaChunkHeader, std::atomic<void*>,
std::atomic<SerialArena*>>::WithStaticSizes</*header*/ 1>;
const char* ptr() const { return reinterpret_cast<const char*>(this); }
char* ptr() { return reinterpret_cast<char*>(this); }
@ -529,7 +530,7 @@ class ThreadSafeArena::SerialArenaChunk {
}
constexpr static layout_type Layout(size_t n) {
return layout_type(/*header*/ 1, /*ids*/ n, /*arenas*/ n);
return layout_type(/*ids*/ n, /*arenas*/ n);
}
layout_type Layout() const { return Layout(capacity()); }
};

Loading…
Cancel
Save