From 5b83e771ed70870374defeade7feba3118a6abb8 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 16 Feb 2024 13:06:57 +0100 Subject: [PATCH 1/6] Print CPU flags at startup --- programs/server/Server.cpp | 15 +++++ src/Common/{CpuId.h => CPUID.h} | 91 +++++++++++++++--------------- src/Common/ProfileEvents.cpp | 8 +-- src/Common/TargetSpecific.cpp | 22 ++++---- src/Common/ThreadProfileEvents.cpp | 16 +++--- src/Functions/FunctionsJSON.h | 2 +- src/Functions/divide/divide.cpp | 6 +- 7 files changed, 87 insertions(+), 73 deletions(-) rename src/Common/{CpuId.h => CPUID.h} (68%) diff --git a/programs/server/Server.cpp b/programs/server/Server.cpp index 53fc32663e79..b85bf6f814ff 100644 --- a/programs/server/Server.cpp +++ b/programs/server/Server.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -712,6 +713,20 @@ try getNumberOfPhysicalCPUCores(), // on ARM processors it can show only enabled at current moment cores std::thread::hardware_concurrency()); + String cpu_info; +#define COLLECT_FLAG(X) \ + if (CPU::have##X()) \ + { \ + if (!cpu_info.empty()) \ + cpu_info += ", "; \ + cpu_info += #X; \ + } + + CPU_ID_ENUMERATE(COLLECT_FLAG) +#undef COLLECT_FLAG + + LOG_INFO(log, "Available CPU instructions: {}", cpu_info); + sanityChecks(*this); // Initialize global thread pool. Do it before we fetch configs from zookeeper diff --git a/src/Common/CpuId.h b/src/Common/CPUID.h similarity index 68% rename from src/Common/CpuId.h rename to src/Common/CPUID.h index 1d15867289d2..44b608ac1fe9 100644 --- a/src/Common/CpuId.h +++ b/src/Common/CPUID.h @@ -11,7 +11,7 @@ namespace DB { -namespace Cpu +namespace CPU { #if (defined(__x86_64__) || defined(__i386__)) @@ -98,7 +98,7 @@ inline bool cpuid(UInt32 op, UInt32 * res) noexcept /// NOLINT OP(AMXTILE) \ OP(AMXINT8) -union CpuInfo +union CPUInfo { UInt32 info[4]; @@ -110,9 +110,9 @@ union CpuInfo UInt32 edx; } registers; - inline explicit CpuInfo(UInt32 op) noexcept { cpuid(op, info); } + inline explicit CPUInfo(UInt32 op) noexcept { cpuid(op, info); } - inline CpuInfo(UInt32 op, UInt32 sub_op) noexcept { cpuid(op, sub_op, info); } + inline CPUInfo(UInt32 op, UInt32 sub_op) noexcept { cpuid(op, sub_op, info); } }; #define DEF_NAME(X) inline bool have##X() noexcept; @@ -121,67 +121,67 @@ union CpuInfo bool haveRDTSCP() noexcept { - return (CpuInfo(0x80000001).registers.edx >> 27) & 1u; + return (CPUInfo(0x80000001).registers.edx >> 27) & 1u; } bool haveSSE() noexcept { - return (CpuInfo(0x1).registers.edx >> 25) & 1u; + return (CPUInfo(0x1).registers.edx >> 25) & 1u; } bool haveSSE2() noexcept { - return (CpuInfo(0x1).registers.edx >> 26) & 1u; + return (CPUInfo(0x1).registers.edx >> 26) & 1u; } bool haveSSE3() noexcept { - return CpuInfo(0x1).registers.ecx & 1u; + return CPUInfo(0x1).registers.ecx & 1u; } bool havePCLMUL() noexcept { - return (CpuInfo(0x1).registers.ecx >> 1) & 1u; + return (CPUInfo(0x1).registers.ecx >> 1) & 1u; } bool haveSSSE3() noexcept { - return (CpuInfo(0x1).registers.ecx >> 9) & 1u; + return (CPUInfo(0x1).registers.ecx >> 9) & 1u; } bool haveSSE41() noexcept { - return (CpuInfo(0x1).registers.ecx >> 19) & 1u; + return (CPUInfo(0x1).registers.ecx >> 19) & 1u; } bool haveSSE42() noexcept { - return (CpuInfo(0x1).registers.ecx >> 20) & 1u; + return (CPUInfo(0x1).registers.ecx >> 20) & 1u; } bool haveF16C() noexcept { - return (CpuInfo(0x1).registers.ecx >> 29) & 1u; + return (CPUInfo(0x1).registers.ecx >> 29) & 1u; } bool havePOPCNT() noexcept { - return (CpuInfo(0x1).registers.ecx >> 23) & 1u; + return (CPUInfo(0x1).registers.ecx >> 23) & 1u; } bool haveAES() noexcept { - return (CpuInfo(0x1).registers.ecx >> 25) & 1u; + return (CPUInfo(0x1).registers.ecx >> 25) & 1u; } bool haveXSAVE() noexcept { - return (CpuInfo(0x1).registers.ecx >> 26) & 1u; + return (CPUInfo(0x1).registers.ecx >> 26) & 1u; } bool haveOSXSAVE() noexcept { - return (CpuInfo(0x1).registers.ecx >> 27) & 1u; + return (CPUInfo(0x1).registers.ecx >> 27) & 1u; } bool haveAVX() noexcept @@ -191,7 +191,7 @@ bool haveAVX() noexcept // https://bugs.chromium.org/p/chromium/issues/detail?id=375968 return haveOSXSAVE() // implies haveXSAVE() && (our_xgetbv(0) & 6u) == 6u // XMM state and YMM state are enabled by OS - && ((CpuInfo(0x1).registers.ecx >> 28) & 1u); // AVX bit + && ((CPUInfo(0x1).registers.ecx >> 28) & 1u); // AVX bit #else return false; #endif @@ -199,22 +199,22 @@ bool haveAVX() noexcept bool haveFMA() noexcept { - return haveAVX() && ((CpuInfo(0x1).registers.ecx >> 12) & 1u); + return haveAVX() && ((CPUInfo(0x1).registers.ecx >> 12) & 1u); } bool haveAVX2() noexcept { - return haveAVX() && ((CpuInfo(0x7, 0).registers.ebx >> 5) & 1u); + return haveAVX() && ((CPUInfo(0x7, 0).registers.ebx >> 5) & 1u); } bool haveBMI1() noexcept { - return (CpuInfo(0x7, 0).registers.ebx >> 3) & 1u; + return (CPUInfo(0x7, 0).registers.ebx >> 3) & 1u; } bool haveBMI2() noexcept { - return (CpuInfo(0x7, 0).registers.ebx >> 8) & 1u; + return (CPUInfo(0x7, 0).registers.ebx >> 8) & 1u; } bool haveAVX512F() noexcept @@ -224,8 +224,8 @@ bool haveAVX512F() noexcept return haveOSXSAVE() // implies haveXSAVE() && (our_xgetbv(0) & 6u) == 6u // XMM state and YMM state are enabled by OS && ((our_xgetbv(0) >> 5) & 7u) == 7u // ZMM state is enabled by OS - && CpuInfo(0x0).registers.eax >= 0x7 // leaf 7 is present - && ((CpuInfo(0x7, 0).registers.ebx >> 16) & 1u); // AVX512F bit + && CPUInfo(0x0).registers.eax >= 0x7 // leaf 7 is present + && ((CPUInfo(0x7, 0).registers.ebx >> 16) & 1u); // AVX512F bit #else return false; #endif @@ -233,87 +233,87 @@ bool haveAVX512F() noexcept bool haveAVX512DQ() noexcept { - return haveAVX512F() && ((CpuInfo(0x7, 0).registers.ebx >> 17) & 1u); + return haveAVX512F() && ((CPUInfo(0x7, 0).registers.ebx >> 17) & 1u); } bool haveRDSEED() noexcept { - return CpuInfo(0x0).registers.eax >= 0x7 && ((CpuInfo(0x7, 0).registers.ebx >> 18) & 1u); + return CPUInfo(0x0).registers.eax >= 0x7 && ((CPUInfo(0x7, 0).registers.ebx >> 18) & 1u); } bool haveADX() noexcept { - return CpuInfo(0x0).registers.eax >= 0x7 && ((CpuInfo(0x7, 0).registers.ebx >> 19) & 1u); + return CPUInfo(0x0).registers.eax >= 0x7 && ((CPUInfo(0x7, 0).registers.ebx >> 19) & 1u); } bool haveAVX512IFMA() noexcept { - return haveAVX512F() && ((CpuInfo(0x7, 0).registers.ebx >> 21) & 1u); + return haveAVX512F() && ((CPUInfo(0x7, 0).registers.ebx >> 21) & 1u); } bool havePCOMMIT() noexcept { - return CpuInfo(0x0).registers.eax >= 0x7 && ((CpuInfo(0x7, 0).registers.ebx >> 22) & 1u); + return CPUInfo(0x0).registers.eax >= 0x7 && ((CPUInfo(0x7, 0).registers.ebx >> 22) & 1u); } bool haveCLFLUSHOPT() noexcept { - return CpuInfo(0x0).registers.eax >= 0x7 && ((CpuInfo(0x7, 0).registers.ebx >> 23) & 1u); + return CPUInfo(0x0).registers.eax >= 0x7 && ((CPUInfo(0x7, 0).registers.ebx >> 23) & 1u); } bool haveCLWB() noexcept { - return CpuInfo(0x0).registers.eax >= 0x7 && ((CpuInfo(0x7, 0).registers.ebx >> 24) & 1u); + return CPUInfo(0x0).registers.eax >= 0x7 && ((CPUInfo(0x7, 0).registers.ebx >> 24) & 1u); } bool haveAVX512PF() noexcept { - return haveAVX512F() && ((CpuInfo(0x7, 0).registers.ebx >> 26) & 1u); + return haveAVX512F() && ((CPUInfo(0x7, 0).registers.ebx >> 26) & 1u); } bool haveAVX512ER() noexcept { - return haveAVX512F() && ((CpuInfo(0x7, 0).registers.ebx >> 27) & 1u); + return haveAVX512F() && ((CPUInfo(0x7, 0).registers.ebx >> 27) & 1u); } bool haveAVX512CD() noexcept { - return haveAVX512F() && ((CpuInfo(0x7, 0).registers.ebx >> 28) & 1u); + return haveAVX512F() && ((CPUInfo(0x7, 0).registers.ebx >> 28) & 1u); } bool haveSHA() noexcept { - return CpuInfo(0x0).registers.eax >= 0x7 && ((CpuInfo(0x7, 0).registers.ebx >> 29) & 1u); + return CPUInfo(0x0).registers.eax >= 0x7 && ((CPUInfo(0x7, 0).registers.ebx >> 29) & 1u); } bool haveAVX512BW() noexcept { - return haveAVX512F() && ((CpuInfo(0x7, 0).registers.ebx >> 30) & 1u); + return haveAVX512F() && ((CPUInfo(0x7, 0).registers.ebx >> 30) & 1u); } bool haveAVX512VL() noexcept { - return haveAVX512F() && ((CpuInfo(0x7, 0).registers.ebx >> 31) & 1u); + return haveAVX512F() && ((CPUInfo(0x7, 0).registers.ebx >> 31) & 1u); } bool havePREFETCHWT1() noexcept { - return CpuInfo(0x0).registers.eax >= 0x7 && ((CpuInfo(0x7, 0).registers.ecx >> 0) & 1u); + return CPUInfo(0x0).registers.eax >= 0x7 && ((CPUInfo(0x7, 0).registers.ecx >> 0) & 1u); } bool haveAVX512VBMI() noexcept { - return haveAVX512F() && ((CpuInfo(0x7, 0).registers.ecx >> 1) & 1u); + return haveAVX512F() && ((CPUInfo(0x7, 0).registers.ecx >> 1) & 1u); } bool haveAVX512VBMI2() noexcept { - return haveAVX512F() && ((CpuInfo(0x7, 0).registers.ecx >> 6) & 1u); + return haveAVX512F() && ((CPUInfo(0x7, 0).registers.ecx >> 6) & 1u); } bool haveRDRAND() noexcept { - return CpuInfo(0x0).registers.eax >= 0x7 && ((CpuInfo(0x1).registers.ecx >> 30) & 1u); + return CPUInfo(0x0).registers.eax >= 0x7 && ((CPUInfo(0x1).registers.ecx >> 30) & 1u); } inline bool haveAMX() noexcept @@ -330,22 +330,22 @@ inline bool haveAMX() noexcept bool haveAMXBF16() noexcept { return haveAMX() - && ((CpuInfo(0x7, 0).registers.edx >> 22) & 1u); // AMX-BF16 bit + && ((CPUInfo(0x7, 0).registers.edx >> 22) & 1u); // AMX-BF16 bit } bool haveAMXTILE() noexcept { return haveAMX() - && ((CpuInfo(0x7, 0).registers.edx >> 24) & 1u); // AMX-TILE bit + && ((CPUInfo(0x7, 0).registers.edx >> 24) & 1u); // AMX-TILE bit } bool haveAMXINT8() noexcept { return haveAMX() - && ((CpuInfo(0x7, 0).registers.edx >> 25) & 1u); // AMX-INT8 bit + && ((CPUInfo(0x7, 0).registers.edx >> 25) & 1u); // AMX-INT8 bit } -struct CpuFlagsCache +struct CPUFlagsCache { #define DEF_NAME(X) static inline bool have_##X = have##X(); CPU_ID_ENUMERATE(DEF_NAME) @@ -354,4 +354,3 @@ struct CpuFlagsCache } } - diff --git a/src/Common/ProfileEvents.cpp b/src/Common/ProfileEvents.cpp index bdc5d2d88a80..679da441c762 100644 --- a/src/Common/ProfileEvents.cpp +++ b/src/Common/ProfileEvents.cpp @@ -310,7 +310,7 @@ The server successfully detected this situation and will download merged part fr M(ParallelReplicasStealingLeftoversMicroseconds, "Time spent collecting orphaned segments") \ M(ParallelReplicasCollectingOwnedSegmentsMicroseconds, "Time spent collecting segments meant by hash") \ \ - M(PerfCpuCycles, "Total cycles. Be wary of what happens during CPU frequency scaling.") \ + M(PerfCPUCycles, "Total cycles. Be wary of what happens during CPU frequency scaling.") \ M(PerfInstructions, "Retired instructions. Be careful, these can be affected by various issues, most notably hardware interrupt counts.") \ M(PerfCacheReferences, "Cache accesses. Usually, this indicates Last Level Cache accesses, but this may vary depending on your CPU. This may include prefetches and coherency messages; again this depends on the design of your CPU.") \ M(PerfCacheMisses, "Cache misses. Usually this indicates Last Level Cache misses; this is intended to be used in conjunction with the PERFCOUNTHWCACHEREFERENCES event to calculate cache miss rates.") \ @@ -319,12 +319,12 @@ The server successfully detected this situation and will download merged part fr M(PerfBusCycles, "Bus cycles, which can be different from total cycles.") \ M(PerfStalledCyclesFrontend, "Stalled cycles during issue.") \ M(PerfStalledCyclesBackend, "Stalled cycles during retirement.") \ - M(PerfRefCpuCycles, "Total cycles; not affected by CPU frequency scaling.") \ + M(PerfRefCPUCycles, "Total cycles; not affected by CPU frequency scaling.") \ \ - M(PerfCpuClock, "The CPU clock, a high-resolution per-CPU timer") \ + M(PerfCPUClock, "The CPU clock, a high-resolution per-CPU timer") \ M(PerfTaskClock, "A clock count specific to the task that is running") \ M(PerfContextSwitches, "Number of context switches") \ - M(PerfCpuMigrations, "Number of times the process has migrated to a new CPU") \ + M(PerfCPUMigrations, "Number of times the process has migrated to a new CPU") \ M(PerfAlignmentFaults, "Number of alignment faults. These happen when unaligned memory accesses happen; the kernel can handle these but it reduces performance. This happens only on some architectures (never on x86).") \ M(PerfEmulationFaults, "Number of emulation faults. The kernel sometimes traps on unimplemented instructions and emulates them for user space. This can negatively impact performance.") \ M(PerfMinEnabledTime, "For all events, minimum time that an event was enabled. Used to track event multiplexing influence") \ diff --git a/src/Common/TargetSpecific.cpp b/src/Common/TargetSpecific.cpp index b115d3a8734c..49f396c09263 100644 --- a/src/Common/TargetSpecific.cpp +++ b/src/Common/TargetSpecific.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include namespace DB { @@ -9,25 +9,25 @@ namespace DB UInt32 getSupportedArchs() { UInt32 result = 0; - if (Cpu::CpuFlagsCache::have_SSE42) + if (CPU::CPUFlagsCache::have_SSE42) result |= static_cast(TargetArch::SSE42); - if (Cpu::CpuFlagsCache::have_AVX) + if (CPU::CPUFlagsCache::have_AVX) result |= static_cast(TargetArch::AVX); - if (Cpu::CpuFlagsCache::have_AVX2) + if (CPU::CPUFlagsCache::have_AVX2) result |= static_cast(TargetArch::AVX2); - if (Cpu::CpuFlagsCache::have_AVX512F) + if (CPU::CPUFlagsCache::have_AVX512F) result |= static_cast(TargetArch::AVX512F); - if (Cpu::CpuFlagsCache::have_AVX512BW) + if (CPU::CPUFlagsCache::have_AVX512BW) result |= static_cast(TargetArch::AVX512BW); - if (Cpu::CpuFlagsCache::have_AVX512VBMI) + if (CPU::CPUFlagsCache::have_AVX512VBMI) result |= static_cast(TargetArch::AVX512VBMI); - if (Cpu::CpuFlagsCache::have_AVX512VBMI2) + if (CPU::CPUFlagsCache::have_AVX512VBMI2) result |= static_cast(TargetArch::AVX512VBMI2); - if (Cpu::CpuFlagsCache::have_AMXBF16) + if (CPU::CPUFlagsCache::have_AMXBF16) result |= static_cast(TargetArch::AMXBF16); - if (Cpu::CpuFlagsCache::have_AMXTILE) + if (CPU::CPUFlagsCache::have_AMXTILE) result |= static_cast(TargetArch::AMXTILE); - if (Cpu::CpuFlagsCache::have_AMXINT8) + if (CPU::CPUFlagsCache::have_AMXINT8) result |= static_cast(TargetArch::AMXINT8); return result; } diff --git a/src/Common/ThreadProfileEvents.cpp b/src/Common/ThreadProfileEvents.cpp index 990151d73fff..40ea1f43449c 100644 --- a/src/Common/ThreadProfileEvents.cpp +++ b/src/Common/ThreadProfileEvents.cpp @@ -36,7 +36,7 @@ namespace ProfileEvents extern const Event OSReadBytes; extern const Event OSWriteBytes; - extern const Event PerfCpuCycles; + extern const Event PerfCPUCycles; extern const Event PerfInstructions; extern const Event PerfCacheReferences; extern const Event PerfCacheMisses; @@ -45,12 +45,12 @@ namespace ProfileEvents extern const Event PerfBusCycles; extern const Event PerfStalledCyclesFrontend; extern const Event PerfStalledCyclesBackend; - extern const Event PerfRefCpuCycles; + extern const Event PerfRefCPUCycles; - extern const Event PerfCpuClock; + extern const Event PerfCPUClock; extern const Event PerfTaskClock; extern const Event PerfContextSwitches; - extern const Event PerfCpuMigrations; + extern const Event PerfCPUMigrations; extern const Event PerfAlignmentFaults; extern const Event PerfEmulationFaults; extern const Event PerfMinEnabledTime; @@ -218,7 +218,7 @@ thread_local PerfEventsCounters current_thread_counters; // descriptions' source: http://man7.org/linux/man-pages/man2/perf_event_open.2.html static const PerfEventInfo raw_events_info[] = { - HARDWARE_EVENT(PERF_COUNT_HW_CPU_CYCLES, PerfCpuCycles), + HARDWARE_EVENT(PERF_COUNT_HW_CPU_CYCLES, PerfCPUCycles), HARDWARE_EVENT(PERF_COUNT_HW_INSTRUCTIONS, PerfInstructions), HARDWARE_EVENT(PERF_COUNT_HW_CACHE_REFERENCES, PerfCacheReferences), HARDWARE_EVENT(PERF_COUNT_HW_CACHE_MISSES, PerfCacheMisses), @@ -227,13 +227,13 @@ static const PerfEventInfo raw_events_info[] = { HARDWARE_EVENT(PERF_COUNT_HW_BUS_CYCLES, PerfBusCycles), HARDWARE_EVENT(PERF_COUNT_HW_STALLED_CYCLES_FRONTEND, PerfStalledCyclesFrontend), HARDWARE_EVENT(PERF_COUNT_HW_STALLED_CYCLES_BACKEND, PerfStalledCyclesBackend), - HARDWARE_EVENT(PERF_COUNT_HW_REF_CPU_CYCLES, PerfRefCpuCycles), + HARDWARE_EVENT(PERF_COUNT_HW_REF_CPU_CYCLES, PerfRefCPUCycles), // `cpu-clock` is a bit broken according to this: https://stackoverflow.com/a/56967896 - SOFTWARE_EVENT(PERF_COUNT_SW_CPU_CLOCK, PerfCpuClock), + SOFTWARE_EVENT(PERF_COUNT_SW_CPU_CLOCK, PerfCPUClock), SOFTWARE_EVENT(PERF_COUNT_SW_TASK_CLOCK, PerfTaskClock), SOFTWARE_EVENT(PERF_COUNT_SW_CONTEXT_SWITCHES, PerfContextSwitches), - SOFTWARE_EVENT(PERF_COUNT_SW_CPU_MIGRATIONS, PerfCpuMigrations), + SOFTWARE_EVENT(PERF_COUNT_SW_CPU_MIGRATIONS, PerfCPUMigrations), SOFTWARE_EVENT(PERF_COUNT_SW_ALIGNMENT_FAULTS, PerfAlignmentFaults), SOFTWARE_EVENT(PERF_COUNT_SW_EMULATION_FAULTS, PerfEmulationFaults), diff --git a/src/Functions/FunctionsJSON.h b/src/Functions/FunctionsJSON.h index 31a99475b63b..2539fa1aeb43 100644 --- a/src/Functions/FunctionsJSON.h +++ b/src/Functions/FunctionsJSON.h @@ -5,7 +5,7 @@ #include -#include +#include #include #include diff --git a/src/Functions/divide/divide.cpp b/src/Functions/divide/divide.cpp index 6262d42a6663..0708964c7d4d 100644 --- a/src/Functions/divide/divide.cpp +++ b/src/Functions/divide/divide.cpp @@ -1,5 +1,5 @@ #include "divide.h" -#include +#include #if defined(__x86_64__) namespace SSE2 @@ -26,9 +26,9 @@ template void divideImpl(const A * __restrict a_pos, B b, ResultType * __restrict c_pos, size_t size) { #if defined(__x86_64__) - if (DB::Cpu::CpuFlagsCache::have_AVX2) + if (DB::CPU::CPUFlagsCache::have_AVX2) AVX2::divideImpl(a_pos, b, c_pos, size); - else if (DB::Cpu::CpuFlagsCache::have_SSE2) + else if (DB::CPU::CPUFlagsCache::have_SSE2) SSE2::divideImpl(a_pos, b, c_pos, size); #else Generic::divideImpl(a_pos, b, c_pos, size); From 39f363ba6e7dc21c1ac9d8e1dddc92d677e5b302 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 16 Feb 2024 13:09:07 +0100 Subject: [PATCH 2/6] Print CPU flags at startup --- programs/server/Server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/server/Server.cpp b/programs/server/Server.cpp index b85bf6f814ff..593c90e44b54 100644 --- a/programs/server/Server.cpp +++ b/programs/server/Server.cpp @@ -725,7 +725,7 @@ try CPU_ID_ENUMERATE(COLLECT_FLAG) #undef COLLECT_FLAG - LOG_INFO(log, "Available CPU instructions: {}", cpu_info); + LOG_INFO(log, "Available CPU instruction sets: {}", cpu_info); sanityChecks(*this); From cb0ce2aaa94a818284ef3147603fa3441a737876 Mon Sep 17 00:00:00 2001 From: Igor Nikonov Date: Fri, 16 Feb 2024 15:26:08 +0000 Subject: [PATCH 3/6] Fix build --- src/Common/ThreadProfileEvents.cpp | 2 -- src/Coordination/KeeperConstants.cpp | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Common/ThreadProfileEvents.cpp b/src/Common/ThreadProfileEvents.cpp index 40ea1f43449c..6a63d484cd9e 100644 --- a/src/Common/ThreadProfileEvents.cpp +++ b/src/Common/ThreadProfileEvents.cpp @@ -6,10 +6,8 @@ #include "ProcfsMetricsProvider.h" #include "hasLinuxCapability.h" -#include #include #include -#include #include #include diff --git a/src/Coordination/KeeperConstants.cpp b/src/Coordination/KeeperConstants.cpp index 2aa84b691c46..f788095334ed 100644 --- a/src/Coordination/KeeperConstants.cpp +++ b/src/Coordination/KeeperConstants.cpp @@ -85,7 +85,7 @@ M(OSReadChars) \ M(OSWriteChars) \ \ - M(PerfCpuCycles) \ + M(PerfCPUCycles) \ M(PerfInstructions) \ M(PerfCacheReferences) \ M(PerfCacheMisses) \ @@ -94,12 +94,12 @@ M(PerfBusCycles) \ M(PerfStalledCyclesFrontend) \ M(PerfStalledCyclesBackend) \ - M(PerfRefCpuCycles) \ + M(PerfRefCPUCycles) \ \ - M(PerfCpuClock) \ + M(PerfCPUClock) \ M(PerfTaskClock) \ M(PerfContextSwitches) \ - M(PerfCpuMigrations) \ + M(PerfCPUMigrations) \ M(PerfAlignmentFaults) \ M(PerfEmulationFaults) \ M(PerfMinEnabledTime) \ From 509d8ee99ca259db0233fe4c174541753169256d Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 17 Feb 2024 01:54:54 +0100 Subject: [PATCH 4/6] Apply review comments --- programs/server/Server.cpp | 2 ++ src/Common/CPUID.h | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/programs/server/Server.cpp b/programs/server/Server.cpp index 593c90e44b54..0a3c23d746ab 100644 --- a/programs/server/Server.cpp +++ b/programs/server/Server.cpp @@ -713,6 +713,7 @@ try getNumberOfPhysicalCPUCores(), // on ARM processors it can show only enabled at current moment cores std::thread::hardware_concurrency()); +#if defined(__x86_64__) String cpu_info; #define COLLECT_FLAG(X) \ if (CPU::have##X()) \ @@ -726,6 +727,7 @@ try #undef COLLECT_FLAG LOG_INFO(log, "Available CPU instruction sets: {}", cpu_info); +#endif sanityChecks(*this); diff --git a/src/Common/CPUID.h b/src/Common/CPUID.h index 44b608ac1fe9..b47e7e808d72 100644 --- a/src/Common/CPUID.h +++ b/src/Common/CPUID.h @@ -2,7 +2,7 @@ #include -#if defined(__x86_64__) || defined(__i386__) +#if defined(__x86_64__) #include #endif @@ -14,7 +14,7 @@ namespace DB namespace CPU { -#if (defined(__x86_64__) || defined(__i386__)) +#if (defined(__x86_64__)) /// Our version is independent of -mxsave option, because we do dynamic dispatch. inline UInt64 our_xgetbv(UInt32 xcr) noexcept { @@ -30,7 +30,7 @@ inline UInt64 our_xgetbv(UInt32 xcr) noexcept inline bool cpuid(UInt32 op, UInt32 sub_op, UInt32 * res) noexcept /// NOLINT { -#if defined(__x86_64__) || defined(__i386__) +#if defined(__x86_64__) __cpuid_count(op, sub_op, res[0], res[1], res[2], res[3]); return true; #else @@ -45,7 +45,7 @@ inline bool cpuid(UInt32 op, UInt32 sub_op, UInt32 * res) noexcept /// NOLINT inline bool cpuid(UInt32 op, UInt32 * res) noexcept /// NOLINT { -#if defined(__x86_64__) || defined(__i386__) +#if defined(__x86_64__) __cpuid(op, res[0], res[1], res[2], res[3]); return true; #else @@ -186,7 +186,7 @@ bool haveOSXSAVE() noexcept bool haveAVX() noexcept { -#if defined(__x86_64__) || defined(__i386__) +#if defined(__x86_64__) // http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf // https://bugs.chromium.org/p/chromium/issues/detail?id=375968 return haveOSXSAVE() // implies haveXSAVE() @@ -219,7 +219,7 @@ bool haveBMI2() noexcept bool haveAVX512F() noexcept { -#if defined(__x86_64__) || defined(__i386__) +#if defined(__x86_64__) // https://software.intel.com/en-us/articles/how-to-detect-knl-instruction-support return haveOSXSAVE() // implies haveXSAVE() && (our_xgetbv(0) & 6u) == 6u // XMM state and YMM state are enabled by OS @@ -318,7 +318,7 @@ bool haveRDRAND() noexcept inline bool haveAMX() noexcept { -#if defined(__x86_64__) || defined(__i386__) +#if defined(__x86_64__) // http://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-optimization-manual.pdf return haveOSXSAVE() // implies haveXSAVE() && ((our_xgetbv(0) >> 17) & 0x3) == 0x3; // AMX state are enabled by OS From 2f315e0eb54f1b9d93b6c5406287d83f748530ed Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 17 Feb 2024 02:14:15 +0100 Subject: [PATCH 5/6] Style check for abbreviations --- src/Client/ConnectionParameters.cpp | 2 +- src/Dictionaries/YAMLRegExpTreeDictionarySource.cpp | 2 +- src/Functions/serverConstants.cpp | 10 +++++----- src/IO/ConnectionTimeouts.cpp | 6 +++--- src/IO/ConnectionTimeouts.h | 4 ++-- src/IO/S3/Credentials.cpp | 5 +---- src/IO/S3/PocoHTTPClient.cpp | 4 ++-- src/Interpreters/Context.cpp | 2 +- src/Interpreters/Context.h | 2 +- src/Interpreters/InterpreterShowFunctionsQuery.cpp | 4 ++-- src/Interpreters/Session.cpp | 4 ++-- src/Interpreters/Session.h | 2 +- .../Kusto/KustoFunctions/KQLFunctionFactory.cpp | 4 ++-- .../Kusto/KustoFunctions/KQLStringFunctions.cpp | 4 ++-- src/Parsers/Kusto/KustoFunctions/KQLStringFunctions.h | 4 ++-- src/Processors/Formats/Impl/AvroRowInputFormat.cpp | 4 ++-- src/Server/HTTPHandler.cpp | 8 ++++---- src/Storages/StorageURL.cpp | 2 +- utils/check-style/check-style | 6 ++++++ 19 files changed, 41 insertions(+), 38 deletions(-) diff --git a/src/Client/ConnectionParameters.cpp b/src/Client/ConnectionParameters.cpp index a0ae47f06203..5c22b6c6d3f0 100644 --- a/src/Client/ConnectionParameters.cpp +++ b/src/Client/ConnectionParameters.cpp @@ -125,7 +125,7 @@ ConnectionParameters::ConnectionParameters(const Poco::Util::AbstractConfigurati Poco::Timespan(config.getInt("send_timeout", DBMS_DEFAULT_SEND_TIMEOUT_SEC), 0)) .withReceiveTimeout( Poco::Timespan(config.getInt("receive_timeout", DBMS_DEFAULT_RECEIVE_TIMEOUT_SEC), 0)) - .withTcpKeepAliveTimeout( + .withTCPKeepAliveTimeout( Poco::Timespan(config.getInt("tcp_keep_alive_timeout", DEFAULT_TCP_KEEP_ALIVE_TIMEOUT), 0)) .withHandshakeTimeout( Poco::Timespan(config.getInt("handshake_timeout_ms", DBMS_DEFAULT_RECEIVE_TIMEOUT_SEC * 1000) * 1000)) diff --git a/src/Dictionaries/YAMLRegExpTreeDictionarySource.cpp b/src/Dictionaries/YAMLRegExpTreeDictionarySource.cpp index f1591943a122..b35e507b242f 100644 --- a/src/Dictionaries/YAMLRegExpTreeDictionarySource.cpp +++ b/src/Dictionaries/YAMLRegExpTreeDictionarySource.cpp @@ -227,7 +227,7 @@ void parseMatchNode(UInt64 parent_id, UInt64 & id, const YAML::Node & node, Resu if (!match.contains(key_name)) { - throw Exception(ErrorCodes::INVALID_CONFIG_PARAMETER, "Yaml match rule must contain key {}", key_name); + throw Exception(ErrorCodes::INVALID_CONFIG_PARAMETER, "YAML match rule must contain key {}", key_name); } for (const auto & [key, node_] : match) { diff --git a/src/Functions/serverConstants.cpp b/src/Functions/serverConstants.cpp index 9f1a3584df8b..fd8fb22455bf 100644 --- a/src/Functions/serverConstants.cpp +++ b/src/Functions/serverConstants.cpp @@ -51,12 +51,12 @@ namespace }; - class FunctionTcpPort : public FunctionConstantBase + class FunctionTCPPort : public FunctionConstantBase { public: static constexpr auto name = "tcpPort"; - static FunctionPtr create(ContextPtr context) { return std::make_shared(context); } - explicit FunctionTcpPort(ContextPtr context) : FunctionConstantBase(context->getTCPPort(), context->isDistributed()) {} + static FunctionPtr create(ContextPtr context) { return std::make_shared(context); } + explicit FunctionTCPPort(ContextPtr context) : FunctionConstantBase(context->getTCPPort(), context->isDistributed()) {} }; @@ -153,9 +153,9 @@ REGISTER_FUNCTION(ServerUUID) factory.registerFunction(); } -REGISTER_FUNCTION(TcpPort) +REGISTER_FUNCTION(TCPPort) { - factory.registerFunction(); + factory.registerFunction(); } REGISTER_FUNCTION(Timezone) diff --git a/src/IO/ConnectionTimeouts.cpp b/src/IO/ConnectionTimeouts.cpp index ecc0d64580b2..f2db31694006 100644 --- a/src/IO/ConnectionTimeouts.cpp +++ b/src/IO/ConnectionTimeouts.cpp @@ -20,7 +20,7 @@ ConnectionTimeouts ConnectionTimeouts::getTCPTimeoutsWithoutFailover(const Setti .withConnectionTimeout(settings.connect_timeout) .withSendTimeout(settings.send_timeout) .withReceiveTimeout(settings.receive_timeout) - .withTcpKeepAliveTimeout(settings.tcp_keep_alive_timeout) + .withTCPKeepAliveTimeout(settings.tcp_keep_alive_timeout) .withHandshakeTimeout(settings.handshake_timeout_ms) .withHedgedConnectionTimeout(settings.hedged_connection_timeout_ms) .withReceiveDataTimeout(settings.receive_data_timeout_ms); @@ -40,8 +40,8 @@ ConnectionTimeouts ConnectionTimeouts::getHTTPTimeouts(const Settings & settings .withConnectionTimeout(settings.http_connection_timeout) .withSendTimeout(settings.http_send_timeout) .withReceiveTimeout(settings.http_receive_timeout) - .withHttpKeepAliveTimeout(http_keep_alive_timeout) - .withTcpKeepAliveTimeout(settings.tcp_keep_alive_timeout) + .withHTTPKeepAliveTimeout(http_keep_alive_timeout) + .withTCPKeepAliveTimeout(settings.tcp_keep_alive_timeout) .withHandshakeTimeout(settings.handshake_timeout_ms); } diff --git a/src/IO/ConnectionTimeouts.h b/src/IO/ConnectionTimeouts.h index 6967af082043..7fe97b5ec36c 100644 --- a/src/IO/ConnectionTimeouts.h +++ b/src/IO/ConnectionTimeouts.h @@ -16,8 +16,8 @@ struct Settings; M(secure_connection_timeout, withSecureConnectionTimeout) \ M(send_timeout, withSendTimeout) \ M(receive_timeout, withReceiveTimeout) \ - M(tcp_keep_alive_timeout, withTcpKeepAliveTimeout) \ - M(http_keep_alive_timeout, withHttpKeepAliveTimeout) \ + M(tcp_keep_alive_timeout, withTCPKeepAliveTimeout) \ + M(http_keep_alive_timeout, withHTTPKeepAliveTimeout) \ M(hedged_connection_timeout, withHedgedConnectionTimeout) \ M(receive_data_timeout, withReceiveDataTimeout) \ M(handshake_timeout, withHandshakeTimeout) \ diff --git a/src/IO/S3/Credentials.cpp b/src/IO/S3/Credentials.cpp index e64f54b99ad3..80366510b53f 100644 --- a/src/IO/S3/Credentials.cpp +++ b/src/IO/S3/Credentials.cpp @@ -22,7 +22,6 @@ namespace ErrorCodes # include # include -# include # include # include @@ -31,9 +30,7 @@ namespace ErrorCodes # include # include -# include -# include # include # include # include @@ -755,7 +752,7 @@ S3CredentialsProviderChain::S3CredentialsProviderChain( configuration.put_request_throttler, Aws::Http::SchemeMapper::ToString(Aws::Http::Scheme::HTTP)); - /// See MakeDefaultHttpResourceClientConfiguration(). + /// See MakeDefaultHTTPResourceClientConfiguration(). /// This is part of EC2 metadata client, but unfortunately it can't be accessed from outside /// of contrib/aws/aws-cpp-sdk-core/source/internal/AWSHttpResourceClient.cpp aws_client_configuration.maxConnections = 2; diff --git a/src/IO/S3/PocoHTTPClient.cpp b/src/IO/S3/PocoHTTPClient.cpp index 21acdfd69f26..dbb93e63143d 100644 --- a/src/IO/S3/PocoHTTPClient.cpp +++ b/src/IO/S3/PocoHTTPClient.cpp @@ -146,9 +146,9 @@ ConnectionTimeouts getTimeoutsFromConfiguration(const PocoHTTPClientConfiguratio .withConnectionTimeout(Poco::Timespan(client_configuration.connectTimeoutMs * 1000)) .withSendTimeout(Poco::Timespan(client_configuration.requestTimeoutMs * 1000)) .withReceiveTimeout(Poco::Timespan(client_configuration.requestTimeoutMs * 1000)) - .withTcpKeepAliveTimeout(Poco::Timespan( + .withTCPKeepAliveTimeout(Poco::Timespan( client_configuration.enableTcpKeepAlive ? client_configuration.tcpKeepAliveIntervalMs * 1000 : 0)) - .withHttpKeepAliveTimeout(Poco::Timespan( + .withHTTPKeepAliveTimeout(Poco::Timespan( client_configuration.http_keep_alive_timeout_ms * 1000)); /// flag indicating whether keep-alive is enabled is set to each session upon creation } diff --git a/src/Interpreters/Context.cpp b/src/Interpreters/Context.cpp index fdd18c9bdebb..1dbf54e675b3 100644 --- a/src/Interpreters/Context.cpp +++ b/src/Interpreters/Context.cpp @@ -4513,7 +4513,7 @@ void Context::setClientConnectionId(uint32_t connection_id_) client_info.connection_id = connection_id_; } -void Context::setHttpClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer) +void Context::setHTTPClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer) { client_info.http_method = http_method; client_info.http_user_agent = http_user_agent; diff --git a/src/Interpreters/Context.h b/src/Interpreters/Context.h index cdd188faa481..a7908d45a9bd 100644 --- a/src/Interpreters/Context.h +++ b/src/Interpreters/Context.h @@ -630,7 +630,7 @@ class Context: public ContextData, public std::enable_shared_from_this void setClientInterface(ClientInfo::Interface interface); void setClientVersion(UInt64 client_version_major, UInt64 client_version_minor, UInt64 client_version_patch, unsigned client_tcp_protocol_version); void setClientConnectionId(uint32_t connection_id); - void setHttpClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer); + void setHTTPClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer); void setForwardedFor(const String & forwarded_for); void setQueryKind(ClientInfo::QueryKind query_kind); void setQueryKindInitial(); diff --git a/src/Interpreters/InterpreterShowFunctionsQuery.cpp b/src/Interpreters/InterpreterShowFunctionsQuery.cpp index e83f61eac53f..829670d7929a 100644 --- a/src/Interpreters/InterpreterShowFunctionsQuery.cpp +++ b/src/Interpreters/InterpreterShowFunctionsQuery.cpp @@ -25,13 +25,13 @@ String InterpreterShowFunctionsQuery::getRewrittenQuery() const auto & query = query_ptr->as(); - DatabasePtr systemDb = DatabaseCatalog::instance().getSystemDatabase(); + DatabasePtr system_db = DatabaseCatalog::instance().getSystemDatabase(); String rewritten_query = fmt::format( R"( SELECT * FROM {}.{})", - systemDb->getDatabaseName(), + system_db->getDatabaseName(), functions_table); if (!query.like.empty()) diff --git a/src/Interpreters/Session.cpp b/src/Interpreters/Session.cpp index df97a09f6863..b52f8a507e37 100644 --- a/src/Interpreters/Session.cpp +++ b/src/Interpreters/Session.cpp @@ -429,11 +429,11 @@ void Session::setClientConnectionId(uint32_t connection_id) prepared_client_info->connection_id = connection_id; } -void Session::setHttpClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer) +void Session::setHTTPClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer) { if (session_context) { - session_context->setHttpClientInfo(http_method, http_user_agent, http_referer); + session_context->setHTTPClientInfo(http_method, http_user_agent, http_referer); } else { diff --git a/src/Interpreters/Session.h b/src/Interpreters/Session.h index cde000d89fa8..334560a33c8c 100644 --- a/src/Interpreters/Session.h +++ b/src/Interpreters/Session.h @@ -65,7 +65,7 @@ class Session void setClientInterface(ClientInfo::Interface interface); void setClientVersion(UInt64 client_version_major, UInt64 client_version_minor, UInt64 client_version_patch, unsigned client_tcp_protocol_version); void setClientConnectionId(uint32_t connection_id); - void setHttpClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer); + void setHTTPClientInfo(ClientInfo::HTTPMethod http_method, const String & http_user_agent, const String & http_referer); void setForwardedFor(const String & forwarded_for); void setQuotaClientKey(const String & quota_key); void setConnectionClientVersion(UInt64 client_version_major, UInt64 client_version_minor, UInt64 client_version_patch, unsigned client_tcp_protocol_version); diff --git a/src/Parsers/Kusto/KustoFunctions/KQLFunctionFactory.cpp b/src/Parsers/Kusto/KustoFunctions/KQLFunctionFactory.cpp index adac892b49d2..044cc2e06223 100644 --- a/src/Parsers/Kusto/KustoFunctions/KQLFunctionFactory.cpp +++ b/src/Parsers/Kusto/KustoFunctions/KQLFunctionFactory.cpp @@ -359,7 +359,7 @@ std::unique_ptr KQLFunctionFactory::get(String & kql_functio return std::make_unique(); case KQLFunctionValue::extract_json: - return std::make_unique(); + return std::make_unique(); case KQLFunctionValue::has_any_index: return std::make_unique(); @@ -389,7 +389,7 @@ std::unique_ptr KQLFunctionFactory::get(String & kql_functio return std::make_unique(); case KQLFunctionValue::parse_json: - return std::make_unique(); + return std::make_unique(); case KQLFunctionValue::parse_url: return std::make_unique(); diff --git a/src/Parsers/Kusto/KustoFunctions/KQLStringFunctions.cpp b/src/Parsers/Kusto/KustoFunctions/KQLStringFunctions.cpp index 0f9ca67d6dc4..afb8809c69ee 100644 --- a/src/Parsers/Kusto/KustoFunctions/KQLStringFunctions.cpp +++ b/src/Parsers/Kusto/KustoFunctions/KQLStringFunctions.cpp @@ -240,7 +240,7 @@ bool ExtractAll::convertImpl(String & out, IParser::Pos & pos) return true; } -bool ExtractJson::convertImpl(String & out, IParser::Pos & pos) +bool ExtractJSON::convertImpl(String & out, IParser::Pos & pos) { String datatype = "String"; ParserKeyword s_kql("typeof"); @@ -431,7 +431,7 @@ bool ParseCSV::convertImpl(String & out, IParser::Pos & pos) return true; } -bool ParseJson::convertImpl(String & out, IParser::Pos & pos) +bool ParseJSON::convertImpl(String & out, IParser::Pos & pos) { const String fn_name = getKQLFunctionName(pos); if (fn_name.empty()) diff --git a/src/Parsers/Kusto/KustoFunctions/KQLStringFunctions.h b/src/Parsers/Kusto/KustoFunctions/KQLStringFunctions.h index 492a59263ecc..e55d07defd04 100644 --- a/src/Parsers/Kusto/KustoFunctions/KQLStringFunctions.h +++ b/src/Parsers/Kusto/KustoFunctions/KQLStringFunctions.h @@ -62,7 +62,7 @@ class ExtractAll : public IParserKQLFunction bool convertImpl(String & out, IParser::Pos & pos) override; }; -class ExtractJson : public IParserKQLFunction +class ExtractJSON : public IParserKQLFunction { protected: const char * getName() const override { return "extract_json(), extractjson()"; } @@ -125,7 +125,7 @@ class ParseCSV : public IParserKQLFunction bool convertImpl(String & out, IParser::Pos & pos) override; }; -class ParseJson : public IParserKQLFunction +class ParseJJSON : public IParserKQLFunction { protected: const char * getName() const override { return "parse_json()"; } diff --git a/src/Processors/Formats/Impl/AvroRowInputFormat.cpp b/src/Processors/Formats/Impl/AvroRowInputFormat.cpp index 8dc8fa516dc0..8ef2cda5587b 100644 --- a/src/Processors/Formats/Impl/AvroRowInputFormat.cpp +++ b/src/Processors/Formats/Impl/AvroRowInputFormat.cpp @@ -212,7 +212,7 @@ static AvroDeserializer::DeserializeFn createDecimalDeserializeFn(const avro::No }; } -static std::string nodeToJson(avro::NodePtr root_node) +static std::string nodeToJSON(avro::NodePtr root_node) { std::ostringstream ss; // STYLE_CHECK_ALLOW_STD_STRING_STREAM ss.exceptions(std::ios::failbit); @@ -641,7 +641,7 @@ AvroDeserializer::DeserializeFn AvroDeserializer::createDeserializeFn(const avro throw Exception(ErrorCodes::ILLEGAL_COLUMN, "Type {} is not compatible with Avro {}:\n{}", - target_type->getName(), avro::toString(root_node->type()), nodeToJson(root_node)); + target_type->getName(), avro::toString(root_node->type()), nodeToJSON(root_node)); } AvroDeserializer::SkipFn AvroDeserializer::createSkipFn(const avro::NodePtr & root_node) diff --git a/src/Server/HTTPHandler.cpp b/src/Server/HTTPHandler.cpp index 72e7c5552f85..35a95c0534d9 100644 --- a/src/Server/HTTPHandler.cpp +++ b/src/Server/HTTPHandler.cpp @@ -125,7 +125,7 @@ namespace ErrorCodes namespace { -bool tryAddHttpOptionHeadersFromConfig(HTTPServerResponse & response, const Poco::Util::LayeredConfiguration & config) +bool tryAddHTTPOptionHeadersFromConfig(HTTPServerResponse & response, const Poco::Util::LayeredConfiguration & config) { if (config.has("http_options_response")) { @@ -153,7 +153,7 @@ bool tryAddHttpOptionHeadersFromConfig(HTTPServerResponse & response, const Poco void processOptionsRequest(HTTPServerResponse & response, const Poco::Util::LayeredConfiguration & config) { /// If can add some headers from config - if (tryAddHttpOptionHeadersFromConfig(response, config)) + if (tryAddHTTPOptionHeadersFromConfig(response, config)) { response.setKeepAlive(false); response.setStatusAndReason(HTTPResponse::HTTP_NO_CONTENT); @@ -496,7 +496,7 @@ bool HTTPHandler::authenticateUser( else if (request.getMethod() == HTTPServerRequest::HTTP_POST) http_method = ClientInfo::HTTPMethod::POST; - session->setHttpClientInfo(http_method, request.get("User-Agent", ""), request.get("Referer", "")); + session->setHTTPClientInfo(http_method, request.get("User-Agent", ""), request.get("Referer", "")); session->setForwardedFor(request.get("X-Forwarded-For", "")); session->setQuotaClientKey(quota_key); @@ -1065,7 +1065,7 @@ void HTTPHandler::handleRequest(HTTPServerRequest & request, HTTPServerResponse response.set("X-ClickHouse-Server-Display-Name", server_display_name); if (!request.get("Origin", "").empty()) - tryAddHttpOptionHeadersFromConfig(response, server.config()); + tryAddHTTPOptionHeadersFromConfig(response, server.config()); /// For keep-alive to work. if (request.getVersion() == HTTPServerRequest::HTTP_1_1) diff --git a/src/Storages/StorageURL.cpp b/src/Storages/StorageURL.cpp index 547342cf4393..6f3599630d39 100644 --- a/src/Storages/StorageURL.cpp +++ b/src/Storages/StorageURL.cpp @@ -1511,7 +1511,7 @@ void StorageURL::processNamedCollectionResult(Configuration & configuration, con && configuration.http_method != Poco::Net::HTTPRequest::HTTP_PUT) throw Exception( ErrorCodes::BAD_ARGUMENTS, - "Http method can be POST or PUT (current: {}). For insert default is POST, for select GET", + "HTTP method can be POST or PUT (current: {}). For insert default is POST, for select GET", configuration.http_method); configuration.format = collection.getOrDefault("format", "auto"); diff --git a/utils/check-style/check-style b/utils/check-style/check-style index f0745ab43f3a..6c12970c4bb9 100755 --- a/utils/check-style/check-style +++ b/utils/check-style/check-style @@ -442,3 +442,9 @@ ls -1d $ROOT_PATH/contrib/*-cmake | xargs -I@ find @ -name 'CMakeLists.txt' -or # DOS/Windows newlines find $ROOT_PATH/{base,src,programs,utils,docs} -name '*.md' -or -name '*.h' -or -name '*.cpp' -or -name '*.js' -or -name '*.py' -or -name '*.html' | xargs grep -l -P '\r$' && echo "^ Files contain DOS/Windows newlines (\r\n instead of \n)." + +# Wrong spelling of abbreviations, e.g. SQL is right, Sql is wrong. XMLHttpRequest is very wrong. +find $ROOT_PATH/{src,base,programs,utils} -name '*.h' -or -name '*.cpp' | + grep -vP $EXCLUDE_DIRS | + xargs grep -P 'Sql|Html|Xml|Cpu|Tcp|Udp|Http|Db|Json|Yaml' | grep -v -P 'RabbitMQ|Azure|Aws|aws|Avro|IO/S3' && + echo "Abbreviations such as SQL, XML, HTTP, should be in all caps. For example, SQL is right, Sql is wrong. XMLHttpRequest is very wrong." From 9686bb51bcbd0e1272ae8f8ad0b5265aff71a6c2 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 17 Feb 2024 02:15:14 +0100 Subject: [PATCH 6/6] Style check for abbreviations --- src/Parsers/Kusto/KustoFunctions/KQLStringFunctions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Parsers/Kusto/KustoFunctions/KQLStringFunctions.h b/src/Parsers/Kusto/KustoFunctions/KQLStringFunctions.h index e55d07defd04..9b0c6327e016 100644 --- a/src/Parsers/Kusto/KustoFunctions/KQLStringFunctions.h +++ b/src/Parsers/Kusto/KustoFunctions/KQLStringFunctions.h @@ -125,7 +125,7 @@ class ParseCSV : public IParserKQLFunction bool convertImpl(String & out, IParser::Pos & pos) override; }; -class ParseJJSON : public IParserKQLFunction +class ParseJSON : public IParserKQLFunction { protected: const char * getName() const override { return "parse_json()"; }