Commit 15d08db6 authored by Charles 'Buck' Krasic's avatar Charles 'Buck' Krasic Committed by Commit Bot

QUIC - add QuicPrefetchT0 to platform.

Profiled on android arm64, seems to speed up
net::QuicUtils::CopyToBuffer() by about 10%, translating to about 0.1%
overall.

Merge internal change: 177612619

R=rch@chromium.org

Bug: 
Change-Id: I7b85a4c91538a73af58c3fdbe32637e51693bd4a
Reviewed-on: https://chromium-review.googlesource.com/804744Reviewed-by: default avatarRyan Hamilton <rch@chromium.org>
Commit-Queue: Buck Krasic <ckrasic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#521430}
parent c36968db
...@@ -1459,6 +1459,7 @@ component("net") { ...@@ -1459,6 +1459,7 @@ component("net") {
"quic/platform/api/quic_mutex.h", "quic/platform/api/quic_mutex.h",
"quic/platform/api/quic_optional.h", "quic/platform/api/quic_optional.h",
"quic/platform/api/quic_pcc_sender.h", "quic/platform/api/quic_pcc_sender.h",
"quic/platform/api/quic_prefetch.h",
"quic/platform/api/quic_ptr_util.h", "quic/platform/api/quic_ptr_util.h",
"quic/platform/api/quic_reconstruct_object.h", "quic/platform/api/quic_reconstruct_object.h",
"quic/platform/api/quic_reference_counted.h", "quic/platform/api/quic_reference_counted.h",
...@@ -1499,6 +1500,7 @@ component("net") { ...@@ -1499,6 +1500,7 @@ component("net") {
"quic/platform/impl/quic_mutex_impl.h", "quic/platform/impl/quic_mutex_impl.h",
"quic/platform/impl/quic_optional_impl.h", "quic/platform/impl/quic_optional_impl.h",
"quic/platform/impl/quic_pcc_sender_impl.h", "quic/platform/impl/quic_pcc_sender_impl.h",
"quic/platform/impl/quic_prefetch_impl.h",
"quic/platform/impl/quic_ptr_util_impl.h", "quic/platform/impl/quic_ptr_util_impl.h",
"quic/platform/impl/quic_reconstruct_object_impl.h", "quic/platform/impl/quic_reconstruct_object_impl.h",
"quic/platform/impl/quic_reference_counted_impl.h", "quic/platform/impl/quic_reference_counted_impl.h",
......
...@@ -11,8 +11,10 @@ ...@@ -11,8 +11,10 @@
#include "base/containers/adapters.h" #include "base/containers/adapters.h"
#include "base/logging.h" #include "base/logging.h"
#include "net/quic/core/quic_constants.h" #include "net/quic/core/quic_constants.h"
#include "net/quic/platform/api/quic_aligned.h"
#include "net/quic/platform/api/quic_bug_tracker.h" #include "net/quic/platform/api/quic_bug_tracker.h"
#include "net/quic/platform/api/quic_flags.h" #include "net/quic/platform/api/quic_flags.h"
#include "net/quic/platform/api/quic_prefetch.h"
using std::string; using std::string;
...@@ -237,16 +239,12 @@ void QuicUtils::CopyToBuffer(const struct iovec* iov, ...@@ -237,16 +239,12 @@ void QuicUtils::CopyToBuffer(const struct iovec* iov,
// generally, the iov_offset is not 0, input iov consists of 2K buffers and // generally, the iov_offset is not 0, input iov consists of 2K buffers and
// the output buffer is ~1.4K. // the output buffer is ~1.4K.
if (copy_len == iov_available && iovnum + 1 < iov_count) { if (copy_len == iov_available && iovnum + 1 < iov_count) {
// TODO(ckrasic) - this is unused without prefetch()
// char* next_base = static_cast<char*>(iov.iov[iovnum + 1].iov_base);
// char* next_base = static_cast<char*>(iov.iov[iovnum + 1].iov_base);
// Prefetch 2 cachelines worth of data to get the prefetcher started; leave // Prefetch 2 cachelines worth of data to get the prefetcher started; leave
// it to the hardware prefetcher after that. // it to the hardware prefetcher after that.
// TODO(ckrasic) - investigate what to do about prefetch directives. char* next_base = static_cast<char*>(iov[iovnum + 1].iov_base);
// ::base::PrefetchT0(next_base); QuicPrefetchT0(next_base);
if (iov[iovnum + 1].iov_len >= 64) { if (iov[iovnum + 1].iov_len >= 64) {
// TODO(ckrasic) - investigate what to do about prefetch directives. QuicPrefetchT0(next_base + QUIC_CACHELINE_SIZE);
// ::base::PrefetchT0(next_base + ABSL_CACHELINE_SIZE);
} }
} }
......
...@@ -10,5 +10,6 @@ ...@@ -10,5 +10,6 @@
#define QUIC_ALIGN_OF QUIC_ALIGN_OF_IMPL #define QUIC_ALIGN_OF QUIC_ALIGN_OF_IMPL
#define QUIC_ALIGNED(X) QUIC_ALIGNED_IMPL(X) #define QUIC_ALIGNED(X) QUIC_ALIGNED_IMPL(X)
#define QUIC_CACHELINE_ALIGNED QUIC_CACHELINE_ALIGNED_IMPL #define QUIC_CACHELINE_ALIGNED QUIC_CACHELINE_ALIGNED_IMPL
#define QUIC_CACHELINE_SIZE QUIC_CACHELINE_SIZE_IMPL
#endif // NET_QUIC_PLATFORM_API_QUIC_ALIGNED_H_ #endif // NET_QUIC_PLATFORM_API_QUIC_ALIGNED_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_QUIC_PLATFORM_API_QUIC_PREFETCH_H_
#define NET_QUIC_PLATFORM_API_QUIC_PREFETCH_H_
#include "net/quic/platform/impl/quic_prefetch_impl.h"
namespace net {
// Move data into the cache before it is read, or "prefetch" it.
//
// The value of `addr` is the address of the memory to prefetch. If
// the target and compiler support it, data prefetch instructions are
// generated. If the prefetch is done some time before the memory is
// read, it may be in the cache by the time the read occurs.
//
// The function names specify the temporal locality heuristic applied,
// using the names of Intel prefetch instructions:
//
// T0 - high degree of temporal locality; data should be left in as
// many levels of the cache possible
// T1 - moderate degree of temporal locality
// T2 - low degree of temporal locality
// Nta - no temporal locality, data need not be left in the cache
// after the read
//
// Incorrect or gratuitous use of these functions can degrade
// performance, so use them only when representative benchmarks show
// an improvement.
inline void QuicPrefetchT0(const void* addr) {
return QuicPrefetchT0Impl(addr);
}
} // namespace net
#endif // NET_QUIC_PLATFORM_API_QUIC_PREFETCH_H_
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
// TODO(rtenneti): Change the default 64 alignas value (used the default // TODO(rtenneti): Change the default 64 alignas value (used the default
// value from ABSL_CACHELINE_SIZE). // value from ABSL_CACHELINE_SIZE).
#define QUIC_CACHELINE_ALIGNED_IMPL ALIGNAS(64) #define QUIC_CACHELINE_SIZE_IMPL (64)
#define QUIC_CACHELINE_ALIGNED_IMPL ALIGNAS(QUIC_CACHELINE_SIZE)
#endif // NET_QUIC_PLATFORM_IMPL_QUIC_ALIGNED_IMPL_H_ #endif // NET_QUIC_PLATFORM_IMPL_QUIC_ALIGNED_IMPL_H_
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_QUIC_PLATFORM_IMPL_QUIC_PREFETCH_IMPL_H_
#define NET_QUIC_PLATFORM_IMPL_QUIC_PREFETCH_IMPL_H_
#if defined(_MSC_VER)
#include <intrin.h>
#endif
namespace net {
inline void QuicPrefetchT0Impl(const void* addr) {
#if defined(__GNUC__)
__builtin_prefetch(addr, 0, 3);
#elif defined(_MSC_VER)
_mm_prefetch(reinterpret_cast<const char*>(addr), _MM_HINT_T0);
#endif
}
} // namespace net
#endif // NET_QUIC_PLATFORM_IMPL_QUIC_PREFETCH_IMPL_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment