Increase default memory cache line size for android

Summary:
ADB packets have a maximum size of 4k. This means the size of memory reads does not affect speed
too much (as long as it fits in one packet). Therefore, I am increasing the default memory read
size for android to 2k. This value is used only if the user has not modified the default
memory-cache-line-size setting.

Reviewers: clayborg, tberghammer

Subscribers: tberghammer, danalbert, srhines, lldb-commits

Differential Revision: http://reviews.llvm.org/D13812

llvm-svn: 250814
This commit is contained in:
Pavel Labath 2015-10-20 10:33:17 +00:00
parent a010cfa592
commit f29914883d
7 changed files with 83 additions and 1 deletions

View File

@ -947,7 +947,6 @@ class ModuleCache;
virtual const std::vector<ConstString> &
GetTrapHandlerSymbolNames ();
//------------------------------------------------------------------
/// Find a support executable that may not live within in the
/// standard locations related to LLDB.
@ -970,6 +969,14 @@ class ModuleCache;
return FileSpec();
}
//------------------------------------------------------------------
/// Allow the platform to set preferred memory cache line size. If non-zero (and the user
/// has not set cache line size explicitly), this value will be used as the cache line
/// size for memory reads.
//------------------------------------------------------------------
virtual uint32_t
GetDefaultMemoryCacheLineSize() { return 0; }
protected:
bool m_is_host;
// Set to true when we are able to actually set the OS version while

View File

@ -28,6 +28,7 @@ using namespace lldb_private;
using namespace lldb_private::platform_android;
static uint32_t g_initialize_count = 0;
static const unsigned int g_android_default_cache_size = 2048; // Fits inside 4k adb packet.
void
PlatformAndroid::Initialize ()
@ -274,6 +275,12 @@ PlatformAndroid::DisconnectRemote()
return error;
}
uint32_t
PlatformAndroid::GetDefaultMemoryCacheLineSize()
{
return g_android_default_cache_size;
}
uint32_t
PlatformAndroid::GetSdkVersion()
{

View File

@ -83,6 +83,9 @@ namespace platform_android {
Error
DisconnectRemote () override;
uint32_t
GetDefaultMemoryCacheLineSize() override;
protected:
const char *
GetCacheHostname () override;

View File

@ -813,6 +813,13 @@ Process::Process(lldb::TargetSP target_sp, Listener &listener, const UnixSignals
eBroadcastInternalStateControlResume);
// We need something valid here, even if just the default UnixSignalsSP.
assert (m_unix_signals_sp && "null m_unix_signals_sp after initialization");
// Allow the platform to override the default cache line size
OptionValueSP value_sp =
m_collection_sp->GetPropertyAtIndex(nullptr, true, ePropertyMemCacheLineSize)->GetValue();
uint32_t platform_cache_line_size = target_sp->GetPlatform()->GetDefaultMemoryCacheLineSize();
if (! value_sp->OptionWasSet() && platform_cache_line_size != 0)
value_sp->SetUInt64Value(platform_cache_line_size);
}
//----------------------------------------------------------------------

View File

@ -0,0 +1,4 @@
LEVEL = ../../make
CXX_SOURCES := main.cpp
include $(LEVEL)/Makefile.rules

View File

@ -0,0 +1,41 @@
"""
Verify the default cache line size for android targets
"""
import os
import unittest2
import lldb
from lldbtest import *
import lldbutil
class DefaultCacheLineSizeTestCase(TestBase):
mydir = TestBase.compute_mydir(__file__)
@skipUnlessPlatform(['android'])
def test_cache_line_size(self):
self.build(dictionary=self.getBuildFlags())
exe = os.path.join(os.getcwd(), "a.out")
target = self.dbg.CreateTarget(exe)
self.assertTrue(target and target.IsValid(), "Target is valid")
breakpoint = target.BreakpointCreateByName("main")
self.assertTrue(breakpoint and breakpoint.IsValid(), "Breakpoint is valid")
# Run the program.
process = target.LaunchSimple(None, None, self.get_process_working_directory())
self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
self.assertEqual(process.GetState(), lldb.eStateStopped, PROCESS_STOPPED)
# check the setting value
self.expect("settings show target.process.memory-cache-line-size", patterns=[" = 2048"])
# Run to completion.
process.Continue()
self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED)
if __name__ == '__main__':
import atexit
lldb.SBDebugger.Initialize()
atexit.register(lambda: lldb.SBDebugger.Terminate())
unittest2.main()

View File

@ -0,0 +1,13 @@
//===-- main.cpp ------------------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
int main ()
{
return 0;
}