Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.3k
GH-33880: [C++] Improve I/O tracing#34168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
3f24850d106c428aba916f9da7ad10a80d6ab34c084e485811a1307a56b853556c52af815d317481bbe41f3adee43a7fbaaf56a2724b5ff837e84e4ed397fc2f7fa9738c46398764d3458c9db4ee28b211163ef107343d7a3a126de1a0a0f6a9b635ecd80c4a28a1dba665bb6212967806bcc1ec8fa9f6d315264407bcb2ccdf2ec45f03fa4e0d49742fc7b6b64ca22898b09378ea4974028cd619522e5b9df0be07d501214874ca50e808cfc9c659File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -27,6 +27,7 @@ | ||
| #include "arrow/record_batch.h" | ||
| #include "arrow/result.h" | ||
| #include "arrow/table.h" | ||
| #include "arrow/util/byte_size.h" | ||
| #include "arrow/util/future.h" | ||
| #include "arrow/util/logging.h" | ||
| #include "arrow/util/map.h" | ||
| @@ -191,9 +192,13 @@ class DatasetWriterFileQueue { | ||
| } | ||
| Result<int64_t> PopAndDeliverStagedBatch() { | ||
| util::tracing::Span span; | ||
| START_SPAN(span, "DatasetWriter::Pop"); | ||
| ARROW_ASSIGN_OR_RAISE(std::shared_ptr<RecordBatch> next_batch, PopStagedBatch()); | ||
| int64_t rows_popped = next_batch->num_rows(); | ||
| rows_currently_staged_ -= next_batch->num_rows(); | ||
| ATTRIBUTE_ON_CURRENT_SPAN("batch.size_rows", next_batch->num_rows()); | ||
| ATTRIBUTE_ON_CURRENT_SPAN("rows_currently_staged", rows_currently_staged_); | ||
| ScheduleBatch(std::move(next_batch)); | ||
| return rows_popped; | ||
| } | ||
| @@ -202,7 +207,15 @@ class DatasetWriterFileQueue { | ||
| Status Push(std::shared_ptr<RecordBatch> batch) { | ||
| uint64_t delta_staged = batch->num_rows(); | ||
| rows_currently_staged_ += delta_staged; | ||
| staged_batches_.push_back(std::move(batch)); | ||
| { | ||
| util::tracing::Span span; | ||
| START_SPAN(span, "DatasetWriter::Push", | ||
| {{"batch.size_rows", batch->num_rows()}, | ||
| {"rows_currently_staged", rows_currently_staged_}, | ||
| {"options_.min_rows_per_group", options_.min_rows_per_group}, | ||
| {"max_rows_staged", writer_state_->max_rows_staged}}); | ||
| staged_batches_.push_back(std::move(batch)); | ||
| } | ||
| while (!staged_batches_.empty() && | ||
| (writer_state_->StagingFull() || | ||
| rows_currently_staged_ >= options_.min_rows_per_group)) { | ||
| @@ -233,6 +246,18 @@ class DatasetWriterFileQueue { | ||
| return DeferNotOk(options_.filesystem->io_context().executor()->Submit( | ||
| [self = this, batch = std::move(next)]() { | ||
| int64_t rows_to_release = batch->num_rows(); | ||
| #ifdef ARROW_WITH_OPENTELEMETRY | ||
| uint64_t size_bytes = util::TotalBufferSize(*batch); | ||
| uint64_t num_buffers = 0; | ||
| for (auto column : batch->columns()) { | ||
| num_buffers += column->data()->buffers.size(); | ||
| } | ||
| util::tracing::Span span; | ||
| START_SPAN(span, "DatasetWriter::WriteNext", | ||
| {{"threadpool", "IO"}, | ||
| {"batch.size_bytes", size_bytes}, | ||
| {"batch.num_buffers", num_buffers}}); | ||
| #endif | ||
| Status status = self->writer_->Write(batch); | ||
| self->writer_state_->rows_in_flight_throttle.Release(rows_to_release); | ||
| return status; | ||
| @@ -261,11 +286,6 @@ class DatasetWriterFileQueue { | ||
| util::AsyncTaskScheduler* file_tasks_ = nullptr; | ||
| }; | ||
| struct WriteTask { | ||
| std::string filename; | ||
| uint64_t num_rows; | ||
| }; | ||
| class DatasetWriterDirectoryQueue { | ||
| public: | ||
| DatasetWriterDirectoryQueue(util::AsyncTaskScheduler* scheduler, std::string directory, | ||
| @@ -301,7 +321,6 @@ class DatasetWriterDirectoryQueue { | ||
| Status StartWrite(const std::shared_ptr<RecordBatch>& batch) { | ||
| rows_written_ += batch->num_rows(); | ||
| WriteTask task{current_filename_, static_cast<uint64_t>(batch->num_rows())}; | ||
| if (!latest_open_file_) { | ||
| ARROW_RETURN_NOT_OK(OpenFileQueue(current_filename_)); | ||
| } | ||
| @@ -351,6 +370,8 @@ class DatasetWriterDirectoryQueue { | ||
| latest_open_file_tasks_ = util::MakeThrottledAsyncTaskGroup( | ||
| scheduler_, 1, /*queue=*/nullptr, std::move(file_finish_task)); | ||
| if (init_future_.is_valid()) { | ||
| util::tracing::Span span; | ||
| START_SPAN(span, "arrow::dataset::WaitForDirectoryInit"); | ||
| latest_open_file_tasks_->AddSimpleTask( | ||
| [init_future = init_future_]() { return init_future; }, | ||
| "DatasetWriter::WaitForDirectoryInit"sv); | ||
| @@ -362,6 +383,8 @@ class DatasetWriterDirectoryQueue { | ||
| uint64_t rows_written() const { return rows_written_; } | ||
| void PrepareDirectory() { | ||
| util::tracing::Span span; | ||
| START_SPAN(span, "arrow::dataset::SubmitPrepareDirectoryTask"); | ||
| if (directory_.empty() || !write_options_.create_dir) { | ||
| return; | ||
| } | ||
| @@ -383,6 +406,8 @@ class DatasetWriterDirectoryQueue { | ||
| if (write_options_.existing_data_behavior == | ||
| ExistingDataBehavior::kDeleteMatchingPartitions) { | ||
| init_task = [this, create_dir_cb, notify_waiters_cb, notify_waiters_on_err_cb] { | ||
| util::tracing::Span span; | ||
| START_SPAN(span, "arrow::dataset::PrepareDirectory"); | ||
| return write_options_.filesystem | ||
| ->DeleteDirContentsAsync(directory_, | ||
| /*missing_dir_ok=*/true) | ||
| @@ -614,12 +639,14 @@ class DatasetWriter::DatasetWriterImpl { | ||
| backpressure = | ||
| writer_state_.rows_in_flight_throttle.Acquire(next_chunk->num_rows()); | ||
| if (!backpressure.is_finished()) { | ||
| EVENT(scheduler_->span(), "DatasetWriter::Backpressure::TooManyRowsQueued"); | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why both | ||
| EVENT_ON_CURRENT_SPAN("DatasetWriter::Backpressure::TooManyRowsQueued"); | ||
| break; | ||
| } | ||
| if (will_open_file) { | ||
| backpressure = writer_state_.open_files_throttle.Acquire(1); | ||
| if (!backpressure.is_finished()) { | ||
| EVENT(scheduler_->span(), "DatasetWriter::Backpressure::TooManyOpenFiles"); | ||
| EVENT_ON_CURRENT_SPAN("DatasetWriter::Backpressure::TooManyOpenFiles"); | ||
| RETURN_NOT_OK(TryCloseLargestFile()); | ||
| break; | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do I need to know
num_buffers?