-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performance improvement in cudf::strings::join_strings for long strin…
…gs (#13283) Improves performance for longer strings with `cudf::strings::join_strings()` API. The new implementation is inspired by recent changes in json/writer_impl.cu which uses the `make_strings_children` factor that accepts an iterator of string pointers to gather the results into a single column of data but does lose some performance for smallish-strings (less than 32 bytes). So the original code is refactored to work on smaller strings. Also, a benchmark implementation is added in this PR to test against various sized input columns. For longer strings, the performance improvement is up to 100x for very long strings (>512 bytes). Reference #13048 Authors: - David Wendt (https://github.com/davidwendt) Approvers: - Yunsong Wang (https://github.com/PointKernel) - Nghia Truong (https://github.com/ttnghia) URL: #13283
- Loading branch information
1 parent
23a77a6
commit 4c456cb
Showing
4 changed files
with
191 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <benchmarks/common/generate_input.hpp> | ||
|
||
#include <cudf/strings/combine.hpp> | ||
#include <cudf/strings/strings_column_view.hpp> | ||
#include <cudf/utilities/default_stream.hpp> | ||
|
||
#include <nvbench/nvbench.cuh> | ||
|
||
static void bench_join(nvbench::state& state) | ||
{ | ||
auto const num_rows = static_cast<cudf::size_type>(state.get_int64("num_rows")); | ||
auto const row_width = static_cast<cudf::size_type>(state.get_int64("row_width")); | ||
|
||
if (static_cast<std::size_t>(num_rows) * static_cast<std::size_t>(row_width) >= | ||
static_cast<std::size_t>(std::numeric_limits<cudf::size_type>::max())) { | ||
state.skip("Skip benchmarks greater than size_type limit"); | ||
} | ||
|
||
data_profile const table_profile = data_profile_builder().distribution( | ||
cudf::type_id::STRING, distribution_id::NORMAL, 0, row_width); | ||
auto const table = | ||
create_random_table({cudf::type_id::STRING}, row_count{num_rows}, table_profile); | ||
cudf::strings_column_view input(table->view().column(0)); | ||
|
||
state.set_cuda_stream(nvbench::make_cuda_stream_view(cudf::get_default_stream().value())); | ||
// gather some throughput statistics as well | ||
auto const chars_size = input.chars_size(); | ||
state.add_element_count(chars_size, "chars_size"); // number of bytes; | ||
state.add_global_memory_reads<nvbench::int8_t>(chars_size); // all bytes are read; | ||
state.add_global_memory_writes<nvbench::int8_t>(chars_size); // all bytes are written | ||
|
||
std::string separator(":"); | ||
std::string narep("null"); | ||
state.exec(nvbench::exec_tag::sync, [&](nvbench::launch& launch) { | ||
auto result = cudf::strings::join_strings(input, separator, narep); | ||
}); | ||
} | ||
|
||
NVBENCH_BENCH(bench_join) | ||
.set_name("strings_join") | ||
.add_int64_axis("row_width", {32, 64, 128, 256, 512, 1024}) | ||
.add_int64_axis("num_rows", {4096, 32768, 262144, 2097152, 16777216}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters