diff options
author | Vamsidhar reddy Gaddam <gvamsi@google.com> | 2023-09-19 09:18:57 +0000 |
---|---|---|
committer | Vamsidhar reddy Gaddam <gvamsi@google.com> | 2023-09-19 09:39:13 +0000 |
commit | 6a008f161d9130eb96b7c6c45dfd721e049d681b (patch) | |
tree | bf1976e9b6f060e14bb2501123e93e1538ff2c2c | |
parent | 18fc8e25c509e891df2cc26fed61ef159670fff0 (diff) | |
download | gamesdk-6a008f161d9130eb96b7c6c45dfd721e049d681b.tar.gz |
Add fidelity parameters to session
Instead of storing fidelity parameters in the json request, it is now
stored as part of the session.
Bug: 301049970
Test: Manual testing using BoatAttack switching QLs
Change-Id: I379430fa9535b09c4aa301b3be1cf50ff65226db
-rw-r--r-- | games-performance-tuner/core/request_info.h | 5 | ||||
-rw-r--r-- | games-performance-tuner/core/session.h | 9 | ||||
-rw-r--r-- | games-performance-tuner/core/tuningfork_impl.cpp | 7 | ||||
-rw-r--r-- | games-performance-tuner/http_backend/json_serializer.cpp | 2 |
4 files changed, 14 insertions, 9 deletions
diff --git a/games-performance-tuner/core/request_info.h b/games-performance-tuner/core/request_info.h index 7bc8d63f..ef654609 100644 --- a/games-performance-tuner/core/request_info.h +++ b/games-performance-tuner/core/request_info.h @@ -21,7 +21,6 @@ #include <vector> #include "meminfo_provider.h" -#include "proto/protobuf_util.h" namespace tuningfork { @@ -32,7 +31,6 @@ class Settings; // game package information and session information. struct RequestInfo { std::string experiment_id; - ProtobufSerialization current_fidelity_parameters; std::string session_id; std::string previous_session_id; uint64_t total_memory_bytes; @@ -54,8 +52,7 @@ struct RequestInfo { int32_t height_pixels; int32_t width_pixels; - // Note that this will include an empty experiment_id and - // current_fidelity_parameters. + // Note that this will include an empty experiment_id static RequestInfo ForThisGameAndDevice(const Settings& settings); // We have a globally accessible cached value diff --git a/games-performance-tuner/core/session.h b/games-performance-tuner/core/session.h index ad9960cb..3b9ddc55 100644 --- a/games-performance-tuner/core/session.h +++ b/games-performance-tuner/core/session.h @@ -26,6 +26,7 @@ #include "histogram.h" #include "loadingtime_metric.h" #include "memory_metric.h" +#include "proto/protobuf_util.h" #include "thermal_metric.h" namespace tuningfork { @@ -135,6 +136,13 @@ class Session { void RecordCrash(CrashReason reason); std::vector<CrashReason> GetCrashReports() const; + void SetFidelityParameters(ProtobufSerialization params) { + current_fidelity_parameters = params; + } + ProtobufSerialization GetFidelityParameters() const { + return current_fidelity_parameters; + } + private: // Get an available metric that has been set up to work with this id. FrameTimeMetricData* TakeFrameTimeData(MetricId id) { @@ -203,6 +211,7 @@ class Session { std::vector<InstrumentationKey> instrumentation_keys_; std::mutex mutex_; mutable std::mutex crash_mutex_; + ProtobufSerialization current_fidelity_parameters; }; } // namespace tuningfork diff --git a/games-performance-tuner/core/tuningfork_impl.cpp b/games-performance-tuner/core/tuningfork_impl.cpp index 1ef36cc0..e9815261 100644 --- a/games-performance-tuner/core/tuningfork_impl.cpp +++ b/games-performance-tuner/core/tuningfork_impl.cpp @@ -300,10 +300,9 @@ TuningFork_ErrorCode TuningForkImpl::GetFidelityParameters( auto result = backend_->GenerateTuningParameters( web_request, training_mode_params_.get(), params_ser, experiment_id); if (result == TUNINGFORK_ERROR_OK) { - RequestInfo::CachedValue().current_fidelity_parameters = params_ser; + current_session_->SetFidelityParameters(params_ser); } else if (training_mode_params_.get()) { - RequestInfo::CachedValue().current_fidelity_parameters = - *training_mode_params_; + current_session_->SetFidelityParameters(*training_mode_params_); } RequestInfo::CachedValue().experiment_id = experiment_id; if (Debugging() && gamesdk::jni::IsValid()) { @@ -615,7 +614,7 @@ TuningFork_ErrorCode TuningForkImpl::SetFidelityParameters( ALOGW("Warning, previous data could not be flushed."); SwapSessions(); } - RequestInfo::CachedValue().current_fidelity_parameters = params; + current_session_->SetFidelityParameters(params); // We clear the experiment id here. RequestInfo::CachedValue().experiment_id = ""; return TUNINGFORK_ERROR_OK; diff --git a/games-performance-tuner/http_backend/json_serializer.cpp b/games-performance-tuner/http_backend/json_serializer.cpp index 3a87ee5a..14f25334 100644 --- a/games-performance-tuner/http_backend/json_serializer.cpp +++ b/games-performance-tuner/http_backend/json_serializer.cpp @@ -140,7 +140,7 @@ Json::object JsonSerializer::TelemetryContextJson( {"tuning_parameters", Json::object{{"experiment_id", request_info.experiment_id}, {"serialized_fidelity_parameters", - B64Encode(request_info.current_fidelity_parameters)}}}, + B64Encode(session_.GetFidelityParameters())}}}, {"duration", DurationToSecondsString(duration)}}; } |