diff --git a/.github/workflows/instcountci.yml b/.github/workflows/instcountci.yml index 39398d12a..e99d39a4e 100644 --- a/.github/workflows/instcountci.yml +++ b/.github/workflows/instcountci.yml @@ -64,11 +64,13 @@ jobs: # Note the current convention is to use the -S and -B options here to specify source # and build directories, but this is only available with CMake 3.13 and higher. # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 - run: cmake $GITHUB_WORKSPACE -DENABLE_OFFLINE_TELEMETRY=False -DCMAKE_BUILD_TYPE=$BUILD_TYPE -G Ninja -DENABLE_VIXL_SIMULATOR=False -DENABLE_VIXL_DISASSEMBLER=True -DENABLE_LTO=False -DENABLE_ASSERTIONS=True + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -G Ninja -DENABLE_VIXL_SIMULATOR=False -DENABLE_VIXL_DISASSEMBLER=True -DENABLE_LTO=False -DENABLE_ASSERTIONS=True - name: Build working-directory: ${{runner.workspace}}/build shell: bash + env: + FEX_DISABLETELEMETRY: 1 # Execute the build. You can specify a specific target with "--target " run: cmake --build . --config $BUILD_TYPE --target CodeSizeValidation instcountci_test_files diff --git a/FEXCore/Source/Interface/Config/Config.json.in b/FEXCore/Source/Interface/Config/Config.json.in index a15977031..98bf7b208 100644 --- a/FEXCore/Source/Interface/Config/Config.json.in +++ b/FEXCore/Source/Interface/Config/Config.json.in @@ -329,6 +329,14 @@ "Allows overriding the SVE width in the vixl simulator.", "Useful as a debugging feature." ] + }, + "DisableTelemetry": { + "Type": "bool", + "Default": "false", + "Desc": [ + "Disables telemetry at runtime.", + "Useful for CI instcountCI mostly" + ] } }, "Logging": { diff --git a/FEXCore/Source/Interface/Context/Context.h b/FEXCore/Source/Interface/Context/Context.h index 0b50d28b6..a4bcb7c99 100644 --- a/FEXCore/Source/Interface/Context/Context.h +++ b/FEXCore/Source/Interface/Context/Context.h @@ -238,6 +238,7 @@ namespace FEXCore::Context { FEX_CONFIG_OPT(ParanoidTSO, PARANOIDTSO); FEX_CONFIG_OPT(CacheObjectCodeCompilation, CACHEOBJECTCODECOMPILATION); FEX_CONFIG_OPT(x87ReducedPrecision, X87REDUCEDPRECISION); + FEX_CONFIG_OPT(DisableTelemetry, DISABLETELEMETRY); } Config; FEXCore::HostFeatures HostFeatures; diff --git a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp index 7ee6fbcec..64d0ca025 100644 --- a/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp +++ b/FEXCore/Source/Interface/Core/OpcodeDispatcher.cpp @@ -4858,6 +4858,11 @@ void OpDispatchBuilder::CheckLegacySegmentRead(OrderedNode *NewNode, uint32_t Se return; } + if (CTX->Config.DisableTelemetry()) { + // Telemetry disabled at runtime. + return; + } + FEXCore::Telemetry::TelemetryType TelemIndex{}; switch (SegmentReg) { case FEXCore::X86Tables::DecodeFlags::FLAG_ES_PREFIX: @@ -4892,6 +4897,11 @@ void OpDispatchBuilder::CheckLegacySegmentWrite(OrderedNode *NewNode, uint32_t S return; } + if (CTX->Config.DisableTelemetry()) { + // Telemetry disabled at runtime. + return; + } + FEXCore::Telemetry::TelemetryType TelemIndex{}; switch (SegmentReg) { case FEXCore::X86Tables::DecodeFlags::FLAG_ES_PREFIX: diff --git a/FEXCore/Source/Utils/Telemetry.cpp b/FEXCore/Source/Utils/Telemetry.cpp index b3d1a3c36..c971d538b 100644 --- a/FEXCore/Source/Utils/Telemetry.cpp +++ b/FEXCore/Source/Utils/Telemetry.cpp @@ -33,7 +33,15 @@ namespace FEXCore::Telemetry { "Uses 32-bit Segment CS", "Uses 32-bit Segment DS", }; + + static bool Enabled {true}; void Initialize() { + FEX_CONFIG_OPT(DisableTelemetry, DISABLETELEMETRY); + if (DisableTelemetry) { + Enabled = false; + return; + } + auto DataDirectory = Config::GetDataDirectory(); DataDirectory += "Telemetry/"; @@ -45,6 +53,10 @@ namespace FEXCore::Telemetry { } void Shutdown(fextl::string const &ApplicationName) { + if (!Enabled) { + return; + } + auto DataDirectory = Config::GetDataDirectory(); DataDirectory += "Telemetry/" + ApplicationName + ".telem"; diff --git a/FEXCore/include/FEXCore/Core/CoreState.h b/FEXCore/include/FEXCore/Core/CoreState.h index 129aa231a..f6663dea6 100644 --- a/FEXCore/include/FEXCore/Core/CoreState.h +++ b/FEXCore/include/FEXCore/Core/CoreState.h @@ -239,9 +239,7 @@ namespace FEXCore::Core { uint64_t FallbackHandlerPointers[FallbackHandlerIndex::OPINDEX_MAX]; uint64_t NamedVectorConstantPointers[FEXCore::IR::NamedVectorConstant::NAMED_VECTOR_MAX]; uint64_t IndexedNamedVectorConstantPointers[FEXCore::IR::IndexNamedVectorConstant::INDEXED_NAMED_VECTOR_MAX]; -#ifndef FEX_DISABLE_TELEMETRY uint64_t TelemetryValueAddresses[FEXCore::Telemetry::TYPE_LAST]; -#endif // Thread Specific /** diff --git a/FEXCore/include/FEXCore/Utils/Telemetry.h b/FEXCore/include/FEXCore/Utils/Telemetry.h index cdeb6e4c3..367b101a7 100644 --- a/FEXCore/include/FEXCore/Utils/Telemetry.h +++ b/FEXCore/include/FEXCore/Utils/Telemetry.h @@ -9,25 +9,6 @@ #include namespace FEXCore::Telemetry { -#ifndef FEX_DISABLE_TELEMETRY - class Value; - - class Value final { - public: - Value() = default; - Value(uint64_t Default) : Data {Default} {} - - uint64_t operator*() const { return Data; } - void operator=(uint64_t Value) { Data = Value; } - void operator|=(uint64_t Value) { Data |= Value; } - void operator++(int) { Data++; } - - std::atomic *GetAddr() { return &Data; } - - private: - std::atomic Data; - }; - enum TelemetryType { TYPE_HAS_SPLIT_LOCKS, TYPE_16BYTE_SPLIT, @@ -51,6 +32,25 @@ namespace FEXCore::Telemetry { TYPE_LAST, }; +#ifndef FEX_DISABLE_TELEMETRY + class Value; + + class Value final { + public: + Value() = default; + Value(uint64_t Default) : Data {Default} {} + + uint64_t operator*() const { return Data; } + void operator=(uint64_t Value) { Data = Value; } + void operator|=(uint64_t Value) { Data |= Value; } + void operator++(int) { Data++; } + + std::atomic *GetAddr() { return &Data; } + + private: + std::atomic Data; + }; + FEX_DEFAULT_VISIBILITY Value &GetTelemetryValue(TelemetryType Type); FEX_DEFAULT_VISIBILITY void Initialize(); diff --git a/Source/Tools/CodeSizeValidation/Main.cpp b/Source/Tools/CodeSizeValidation/Main.cpp index e0855c6c9..9e1ea6a21 100644 --- a/Source/Tools/CodeSizeValidation/Main.cpp +++ b/Source/Tools/CodeSizeValidation/Main.cpp @@ -377,6 +377,8 @@ int main(int argc, char **argv, char **const envp) { FEXCore::Config::EraseSet(FEXCore::Config::CONFIG_DISASSEMBLE, fextl::fmt::format("{}", static_cast(FEXCore::Config::Disassemble::BLOCKS | FEXCore::Config::Disassemble::STATS))); // Choose bitness. FEXCore::Config::EraseSet(FEXCore::Config::CONFIG_IS64BIT_MODE, TestHeaderData->Bitness == 64 ? "1" : "0"); + // Disable telemetry, it can affect instruction counts. + FEXCore::Config::EraseSet(FEXCore::Config::CONFIG_DISABLETELEMETRY, "1"); // Host feature override. Only supports overriding SVE width. enum HostFeatures {