summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Murray <timmurray@google.com>2020-07-13 15:36:38 +0000
committerTim Murray <timmurray@google.com>2020-07-21 16:38:10 +0000
commit37162fb4ff78efd4e0417d0c1ebae503e73878ba (patch)
tree7a071389b9df0b2c2fc349e284d3d92c52b6dc27
parent35f27ff6f6d3b261eba78568c34f25138e4fe402 (diff)
downloadcamera-37162fb4ff78efd4e0417d0c1ebae503e73878ba.tar.gz
use mallopt(M_DECAY_TIME, 1) for camera HAL
saves 5%+ of all cycles in camera HAL Test: simpleperf of camera HAL Bug: 160883639 Change-Id: I7d57c21fd7423453dba923b2b88f06b2dab4ad44
-rw-r--r--common/hal/hidl_service/hidl_camera_device_session.cc6
-rw-r--r--common/hal/hidl_service/hidl_camera_provider.cc2
-rw-r--r--common/hal/hidl_service/service.cc2
3 files changed, 9 insertions, 1 deletions
diff --git a/common/hal/hidl_service/hidl_camera_device_session.cc b/common/hal/hidl_service/hidl_camera_device_session.cc
index 0b3aede..0179805 100644
--- a/common/hal/hidl_service/hidl_camera_device_session.cc
+++ b/common/hal/hidl_service/hidl_camera_device_session.cc
@@ -15,10 +15,13 @@
*/
#define LOG_TAG "GCH_HidlCameraDeviceSession"
+#define ATRACE_TAG ATRACE_TAG_CAMERA
//#define LOG_NDEBUG 0
#include <log/log.h>
#include <cutils/properties.h>
+#include <cutils/trace.h>
+#include <malloc.h>
#include "hidl_camera_device_session.h"
#include "hidl_profiler.h"
@@ -68,6 +71,8 @@ std::unique_ptr<HidlCameraDeviceSession> HidlCameraDeviceSession::Create(
HidlCameraDeviceSession::~HidlCameraDeviceSession() {
close();
+ // camera's closing, so flush any unused malloc pages
+ mallopt(M_PURGE, 0);
}
void HidlCameraDeviceSession::ProcessCaptureResult(
@@ -661,7 +666,6 @@ Return<void> HidlCameraDeviceSession::close() {
auto profiler_item = hidl_profiler::OnCameraClose();
device_session_ = nullptr;
}
-
return Void();
}
diff --git a/common/hal/hidl_service/hidl_camera_provider.cc b/common/hal/hidl_service/hidl_camera_provider.cc
index a7ce5e2..7193a26 100644
--- a/common/hal/hidl_service/hidl_camera_provider.cc
+++ b/common/hal/hidl_service/hidl_camera_provider.cc
@@ -157,6 +157,8 @@ status_t HidlCameraProvider::Initialize() {
};
google_camera_provider_->SetCallback(&camera_provider_callback_);
+ // purge pending malloc pages after initialization
+ mallopt(M_PURGE, 0);
return OK;
}
diff --git a/common/hal/hidl_service/service.cc b/common/hal/hidl_service/service.cc
index 48217b7..2b203d7 100644
--- a/common/hal/hidl_service/service.cc
+++ b/common/hal/hidl_service/service.cc
@@ -23,6 +23,7 @@
#include <android/hardware/camera/provider/2.6/ICameraProvider.h>
#include <binder/ProcessState.h>
#include <hidl/LegacySupport.h>
+#include <malloc.h>
using android::hardware::defaultLazyPassthroughServiceImplementation;
using android::hardware::defaultPassthroughServiceImplementation;
@@ -38,6 +39,7 @@ int main() {
ALOGI("Google camera provider service is starting.");
// The camera HAL may communicate to other vendor components via
// /dev/vndbinder
+ mallopt(M_DECAY_TIME, 1);
android::ProcessState::initWithDriver("/dev/vndbinder");
int res;
if (kLazyService) {