File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ using type_info = ::type_info;
29
29
30
30
#include " absl/base/attributes.h"
31
31
#include " absl/base/macros.h"
32
+ #include " absl/base/optimization.h"
33
+ #include " absl/base/prefetch.h"
32
34
#include " absl/log/absl_check.h"
33
35
#include " absl/utility/internal/if_constexpr.h"
34
36
#include " google/protobuf/arena_align.h"
@@ -665,6 +667,12 @@ PROTOBUF_NOINLINE void* Arena::DefaultConstruct(Arena* arena) {
665
667
666
668
template <typename T>
667
669
PROTOBUF_NOINLINE void * Arena::CopyConstruct (Arena* arena, const void * from) {
670
+ // If the object is larger than half a cache line, prefetch it.
671
+ // This way of prefetching is a little more aggressive than if we
672
+ // condition off a whole cache line, but benchmarks show better results.
673
+ if (sizeof (T) > ABSL_CACHELINE_SIZE / 2 ) {
674
+ PROTOBUF_PREFETCH_WITH_OFFSET (from, 64 );
675
+ }
668
676
static_assert (is_destructor_skippable<T>::value, " " );
669
677
void * mem = arena != nullptr ? arena->AllocateAligned (sizeof (T))
670
678
: ::operator new (sizeof (T));
You can’t perform that action at this time.
0 commit comments