Send profile events for INSERT queries (previously only SELECT was supported)#37391
Send profile events for INSERT queries (previously only SELECT was supported)#37391kssenii merged 5 commits intoClickHouse:masterfrom
Conversation
312d612 to
b3a03e4
Compare
b3a03e4 to
325e1b1
Compare
|
Actually the whole idea of profile events was to render progress bar on client (#28364, cc @novikd ), but for This patch adds proper support for
And also have some caveats/cons:
FWIW right now it does not affect performance. Detailspatched$ time yes | head -n100000000 | clickhouse-client --query="insert into function null('foo String') format TSV"
real 0m2.049s
user 0m8.036s
sys 0m0.647s
$ time yes | head -n100000000 | clickhouse-client --query="insert into function null('foo String') format TSV"
real 0m2.093s
user 0m8.130s
sys 0m0.591supstream$ time yes | head -n100000000 | clickhouse-client --query="insert into function null('foo String') format TSV"
real 0m2.078s
user 0m8.224s
sys 0m0.595s
$ time yes | head -n100000000 | clickhouse-client --query="insert into function null('foo String') format TSV"
real 0m2.050s
user 0m7.960s
sys 0m0.674s |
but it possibly can, later, so not really a caveat? |
Not sure, usually you pass stdin/--file to the client in this case, and so you cannot use interactive mode. |
but progress (+ RAM/CPU usage) can be shown for non-interactive mode |
325e1b1 to
e47fad8
Compare
|
I'm fine with caveats that I've found.
Indeed, and with this patch it will be rendered by the client. |
|
@azat, will DDL be supported as well? For example: It's trivial but I'm wondering if it's been considered or not. |
e47fad8 to
4bd5c33
Compare
No, such queries will not provide ProfileEvents. |
Good to know. Yes, it's probably useless for DDL, except ALTER UPDATE/DELETE.
Thanks @azat. As of now, |
4bd5c33 to
0ee65fd
Compare
|
@Mergifyio update |
✅ Branch has been successfully updated |
780302b to
f53f183
Compare
f53f183 to
026d7f7
Compare
do you know why it hangs? |
Signed-off-by: Azat Khuzhin <[email protected]>
…pported)
Reproducer:
echo "1" | clickhouse-client --query="insert into function null('foo String') format TSV" --print-profile-events --profile-events-delay-ms=-1
However, clickhouse-local is differnt, it does sent the periodically,
but only if query was long enough, i.e.:
# yes | head -n100000 | clickhouse-local --query="insert into function null('foo String') format TSV" --print-profile-events --profile-events-delay-ms=-1
[s1.ch] 2022.05.20 15:20:27 [ 0 ] ContextLock: 10 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] DiskReadElapsedMicroseconds: 29 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] IOBufferAllocBytes: 200000 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] IOBufferAllocs: 1 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] InsertQuery: 1 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] InsertedBytes: 1000000 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] InsertedRows: 100000 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] MemoryTrackerUsage: 1521975 (gauge)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] OSCPUVirtualTimeMicroseconds: 102148 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] OSReadChars: 135700 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] OSWriteChars: 8 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] Query: 1 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] RWLockAcquiredReadLocks: 2 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] ReadBufferFromFileDescriptorRead: 5 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] ReadBufferFromFileDescriptorReadBytes: 134464 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] RealTimeMicroseconds: 293747 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] SoftPageFaults: 382 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] TableFunctionExecute: 1 (increment)
[s1.ch] 2022.05.20 15:20:27 [ 0 ] UserTimeMicroseconds: 102148 (increment)
v2: Proper support ProfileEvents in INSERTs (with protocol change)
v3: Receive profile events on INSERT queries
Signed-off-by: Azat Khuzhin <[email protected]>
In case of all of the above:
- clickhouse-local
- input_format_parallel_parsing=true
- write_progress_on_update=true
It is possible concurrent access to the following:
- writeProgress() (class properties) (guarded with progress_mutex)
- thread_data/host_cpu_usage (guarded with profile_events_mutex)
v2: decrease number of rows for INSERT ProfileEvents test (10 times)
CI: https://s3.amazonaws.com/clickhouse-test-reports/37391/4bd5c335182279dcc5020aa081b13c3044135951/stateless_tests__debug__actions__[1/3].html
v3: decrease number of rows for INSERT ProfileEvents test (10 times) and add a comment
CI: https://s3.amazonaws.com/clickhouse-test-reports/37391/026d7f732cb166c90d6c287b02824b6c7fdebf0c/stateless_tests_flaky_check__address__actions_/runlog.log
Signed-off-by: Azat Khuzhin <[email protected]>
f
Signed-off-by: Azat Khuzhin <[email protected]>
v2: apply black formatting (sigh) Signed-off-by: Azat Khuzhin <[email protected]>
The problem is that now there is mutex for profile events and under thread fuzzer for some of runs 10 mins may not be enough: So I've decreased number of rows for this test and rebased. Note, that w/o thread fuzzer the difference is insignificant: $ time yes | head -n100000000 | ~/ch/tmp/37391/clickhouse client -q "insert into function null('foo String') format TSV" --progress
real 0m2.133s
user 0m8.374s
sys 0m0.616s
$ time yes | head -n100000000 | ~/ch/tmp/37391/clickhouse client -q "insert into function null('foo String') format TSV" --progress
real 0m2.089s
user 0m8.399s
sys 0m0.642s
$ time yes | head -n100000000 | ~/ch/tmp/upstream/clickhouse client -q "insert into function null('foo String') format TSV" --progress
real 0m2.150s
user 0m8.422s
sys 0m0.734s
$ time yes | head -n100000000 | ~/ch/tmp/upstream/clickhouse client -q "insert into function null('foo String') format TSV" --progress
real 0m2.060s
user 0m8.297s
sys 0m0.724s
|
026d7f7 to
68b4f3f
Compare
not related to changes |
Right now RemoteInserter does not read ProfileEvents for INSERT, it handles them only after sending the query or on finish. But ClickHouse#37391 sends them for each INSERT block, but sometimes they can be no ProfileEvents packet, since it sends only non-empty blocks. And this adds too much complexity, and anyway ProfileEvents are useless for the server, so let's send them only if the query is initial (i.e. send by user). Note, that it is okay to change the logic of sending ProfileEvents w/o changing DBMS_TCP_PROTOCOL_VERSION, because there were no public releases with the original patch included yet. Fixes: ClickHouse#37391 Refs: ClickHouse#35075 Signed-off-by: Azat Khuzhin <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Send profile events for INSERT queries (previously only SELECT was supported)
Reproducer:
But note, that in case of
clickhouse-localthey were implicitly supported, but only if query was long enough, i.e.:Fixes: #37241 (cc @alexey-milovidov @zhicwu )