Commit Graph

16 Commits

Author SHA1 Message Date
alesapin
f5c5146153 [RFC] Try to add global Real and CPU trace collector 2024-04-02 18:04:53 +02:00
Maksim Kita
2a327107b6 Updated implementation 2024-01-25 14:31:49 +03:00
Azat Khuzhin
a10aa9ad50 Force libunwind usage (removes gcc_eh support)
libunwind is reentrant and signal safe, and works faster then then
gcc_eh (plus it has some custom patches for problems that have been
found during it's usage in ClickHouse).

gcc_eh may be missing in the system (if gcc was not installed), and
even if it exists clickhouse uses -nodefaultlibs, so some care should be
made to make it work.

Also this library is tiny and there shouln't be any problem to require
it always (there is already tendency to require some contrib libraries,
i.e. poco).

Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
2023-07-08 20:55:50 +02:00
Jiebin Sun
fcadb851c8
Maintain per-thread timer_id rather than create/delete frequently (#48778)
* Maintain per-thread timer_id rather than create/delete frequently

The QueryProfiler will frequently create/delete timer_id globally, which
will result in heavy kernel lock contention.
The idea is to maintain thread-local timer_id. Before create the
timer_id, it should check whether there is a timer_id already. And we
could stop the timer by timer_settime() rather than delete the timer_id
with timer_delete().

Apply the patch and run clickbench on latest 65d671b7c7 ClickHouse with
SPR 112 x 2 vCPUs. Query 4, 0, 5, 3, 15, 32 have 17.5%, 14.4%, 8.3%, 7.9%,
7.1%, 5.8% performance gain. The overall geomean has got 2.5%
performance gain.

Signed-off-by: Jiebin Sun <jiebin.sun@intel.com>

* Pack the timer and delete the timer_id when thread terminates

Pack the timer and related methods into the class. Delete the timer_id
when the thread terminates.

According to the issue (ClickHouse#49965),
all of the SSB queries benefit from this optimization, some have even got
improved by ~30% and the overall QPS could be significantly improved by ~18%.

Signed-off-by: Jiebin Sun <jiebin.sun@intel.com>

* Update src/Common/QueryProfiler.cpp

Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>

* Update src/Common/QueryProfiler.cpp

Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>

* Fix the review issue of QueryProfiler Timer from PR
https://github.com/ClickHouse/ClickHouse/pull/48778.

Signed-off-by: Jiebin Sun <jiebin.sun@intel.com>

* Update src/Common/QueryProfiler.cpp

Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>

* Add two separate CurrentMetrics for created and active timers
in QueryProfiler.

Signed-off-by: Jiebin Sun <jiebin.sun@intel.com>

---------

Signed-off-by: Jiebin Sun <jiebin.sun@intel.com>
Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
Co-authored-by: Nikita Taranov <nikita.taranov@clickhouse.com>
2023-06-14 21:22:09 +02:00
Robert Schulze
78fc36ca49
Generate config.h into ${CONFIG_INCLUDE_PATH}
This makes the target location consistent with other auto-generated
files like config_formats.h, config_core.h, and config_functions.h and
simplifies the build of clickhouse_common.
2022-09-28 12:48:26 +00:00
Maksim Kita
e7772ed434 Fix clang-tidy warnings in Common folder 2022-03-14 18:17:35 +00:00
Azat Khuzhin
0b2de32228 Fix QueryProfiler (query_profiler_{cpu,real}_time_period_ns) reset
Even after timer_delete() the signal can be fired.
Reproducer:

    $ clickhouse-server & # with configured trace_log
    $ clickhouse-benchmark -c2 --query 'select * from numbers(1e6)' --query_profiler_cpu_time_period_ns=1 &
    ...
    2021.12.02 14:28:01.320288 [ 24885 ] {} <Debug> TCPHandler: Processed in 177.055205644 sec.
    User defined signal 2

CI failures:
- https://s3.amazonaws.com/clickhouse-test-reports/32067/8dbc7a8dae17090a18778f29629d8746a1bb9b72/stateful_tests__debug__actions_.html
- https://s3.amazonaws.com/clickhouse-test-reports/32064/c07450a7dce363b7a4c5ca3ab0e833c25e3d46c0/stateful_tests__debug__actions_.html

Fix this by do not reset the signal back, and introduce a flag to ignore
signals after disabling the timer.

Fixes: #31740
2021-12-03 01:33:08 +03:00
Azat Khuzhin
df67af0c88 Fix disabling query profiler
Before there was two incorrect checks:
- timer_id != nullptr, but first timer is 0x0 and the comparison does
  not work
- previous_handler should also be reseted regardless it was nullptr or
  not, plus it also incorrectly uses 'sigaction * previous_handler'
  before.

Which leads to permanent query profiler enabled for particular thread,
this is especially visible if you have query profiler disabled and you
are running some query with profiler enabled, i.e.:

  select 1 settings query_profiler_real_time_period_ns=1

After, QueryPipelineEx will eat lots of CPU due because of profiler.
2021-11-24 23:28:20 +03:00
Alexey Milovidov
8b4a6a2416 Remove cruft 2021-10-28 02:10:39 +03:00
Alexey Milovidov
fe6b7c77c7 Rename "common" to "base" 2021-10-02 10:13:14 +03:00
Alexey Milovidov
53ca1ebca6 Be in style 2021-08-25 03:58:49 +03:00
Artem Zuikov
51ba12c2c3
Try speedup build (#14809) 2020-09-15 12:55:57 +03:00
Alexey Milovidov
edd89a8610 Fix half of typos 2020-08-08 03:47:03 +03:00
Ivan
85d783c247
Poco contrib refactoring (#10396)
* Remove config_common.h
* Refactor libcpuid contrib
* Remove support for libcpuinfo
* Define USE_CPUID in Arcadia
* Refactor Poco libraries
2020-05-08 17:11:19 +03:00
Ivan Lezhankin
e230632645 Changes required for auto-sync with Arcadia 2020-04-16 15:31:57 +03:00
Ivan Lezhankin
06446b4f08 dbms/ → src/ 2020-04-03 18:14:31 +03:00