-
Notifications
You must be signed in to change notification settings - Fork 459
feat(storage): add telemetry for pre-warmed ranges in ObjectDescriptorImpl #16323
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -231,7 +231,10 @@ std::unique_ptr<storage::AsyncReaderConnection> ObjectDescriptorImpl::Read( | |
| // Check if this range matches a pre-warmed range. | ||
| auto cache_key = std::make_pair(p.start, p.length); | ||
| auto cache_it = prewarmed_ranges_.find(cache_key); | ||
| absl::string_view cache_status = "MISS"; | ||
|
Contributor
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. nit: Consider making it an enum. |
||
|
|
||
| if (cache_it != prewarmed_ranges_.end()) { | ||
| cache_status = "HIT"; | ||
| // Cache hit. Claim the pre-warmed range and return it to the user. | ||
| auto prewarmed = std::move(cache_it->second); | ||
| prewarmed_ranges_.erase(cache_it); | ||
|
|
@@ -247,7 +250,13 @@ std::unique_ptr<storage::AsyncReaderConnection> ObjectDescriptorImpl::Read( | |
| return std::unique_ptr<storage::AsyncReaderConnection>( | ||
| std::make_unique<ObjectDescriptorReader>(std::move(prewarmed.range))); | ||
| } | ||
| return MakeTracingObjectDescriptorReader(std::move(prewarmed.range)); | ||
| return MakeTracingObjectDescriptorReader(std::move(prewarmed.range), | ||
| cache_status); | ||
| } | ||
|
|
||
| // If not hit, check if it was evicted earlier due to pacing. | ||
| if (evicted_ranges_.erase(cache_key) != 0) { | ||
| cache_status = "EVICTED"; | ||
| } | ||
|
|
||
| if (stream_manager_->Empty()) { | ||
|
|
@@ -258,7 +267,7 @@ std::unique_ptr<storage::AsyncReaderConnection> ObjectDescriptorImpl::Read( | |
| return std::unique_ptr<storage::AsyncReaderConnection>( | ||
| std::make_unique<ObjectDescriptorReader>(std::move(range))); | ||
| } | ||
| return MakeTracingObjectDescriptorReader(std::move(range)); | ||
| return MakeTracingObjectDescriptorReader(std::move(range), cache_status); | ||
| } | ||
|
|
||
| auto it = stream_manager_->GetLeastBusyStream(); | ||
|
|
@@ -274,8 +283,7 @@ std::unique_ptr<storage::AsyncReaderConnection> ObjectDescriptorImpl::Read( | |
| return std::unique_ptr<storage::AsyncReaderConnection>( | ||
| std::make_unique<ObjectDescriptorReader>(std::move(range))); | ||
| } | ||
|
|
||
| return MakeTracingObjectDescriptorReader(std::move(range)); | ||
| return MakeTracingObjectDescriptorReader(std::move(range), cache_status); | ||
| } | ||
|
|
||
| std::shared_ptr<storage::internal::HashFunction> | ||
|
|
@@ -429,6 +437,9 @@ void ObjectDescriptorImpl::OnRead( | |
| max_prewarmed_buffer_size_) { | ||
| // Evict the range if it exceeds the pacing limit. | ||
| total_prewarmed_bytes_buffered_ -= unclaimed_it->second.bytes_buffered; | ||
| if (evicted_ranges_.size() < 1000) { | ||
|
Contributor
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. nit: Can you please put a comment explaining this? |
||
| evicted_ranges_.insert(unclaimed_it->second.cache_it->first); | ||
| } | ||
| prewarmed_ranges_.erase(unclaimed_it->second.cache_it); | ||
| unclaimed_ranges_.erase(unclaimed_it); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,13 +31,17 @@ namespace sc = ::opentelemetry::semconv; | |
|
|
||
| class ObjectDescriptorReaderTracing : public ObjectDescriptorReader { | ||
| public: | ||
| explicit ObjectDescriptorReaderTracing(std::shared_ptr<ReadRange> impl) | ||
| : ObjectDescriptorReader(std::move(impl)) {} | ||
| explicit ObjectDescriptorReaderTracing(std::shared_ptr<ReadRange> impl, | ||
| absl::string_view cache_status) | ||
| : ObjectDescriptorReader(std::move(impl)), cache_status_(cache_status) {} | ||
|
|
||
| ~ObjectDescriptorReaderTracing() override = default; | ||
|
|
||
| future<ObjectDescriptorReader::ReadResponse> Read() override { | ||
| auto span = internal::MakeSpan("storage::AsyncConnection::ReadRange"); | ||
| if (!cache_status_.empty()) { | ||
| span->SetAttribute("fast_open_cache_status", std::string(cache_status_)); | ||
|
Contributor
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. Same comment as above for attribute name. |
||
| } | ||
| internal::OTelScope scope(span); | ||
| return ObjectDescriptorReader::Read().then( | ||
| [span = std::move(span), | ||
|
|
@@ -64,13 +68,18 @@ class ObjectDescriptorReaderTracing : public ObjectDescriptorReader { | |
| return result; | ||
| }); | ||
| } | ||
|
|
||
| private: | ||
| absl::string_view cache_status_; | ||
| }; | ||
|
|
||
| } // namespace | ||
|
|
||
| std::unique_ptr<storage::AsyncReaderConnection> | ||
| MakeTracingObjectDescriptorReader(std::shared_ptr<ReadRange> impl) { | ||
| return std::make_unique<ObjectDescriptorReaderTracing>(std::move(impl)); | ||
| MakeTracingObjectDescriptorReader(std::shared_ptr<ReadRange> impl, | ||
| absl::string_view cache_status) { | ||
| return std::make_unique<ObjectDescriptorReaderTracing>(std::move(impl), | ||
| cache_status); | ||
| } | ||
|
kalragauri marked this conversation as resolved.
|
||
|
|
||
| GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,7 +45,8 @@ TEST(ObjectDescriptorReaderTracing, Read) { | |
| auto span_catcher = InstallSpanCatcher(); | ||
|
|
||
| auto impl = std::make_shared<ReadRange>(10000, 30); | ||
| auto reader = MakeTracingObjectDescriptorReader(impl); | ||
| auto reader = | ||
| MakeTracingObjectDescriptorReader(impl, /*cache_status=*/"TEST"); | ||
|
|
||
| auto data = google::storage::v2::ObjectRangeData{}; | ||
| auto constexpr kData0 = R"pb( | ||
|
|
@@ -73,7 +74,8 @@ TEST(ObjectDescriptorReaderTracing, Read) { | |
| TEST(ObjectDescriptorReaderTracing, ReadError) { | ||
| auto span_catcher = InstallSpanCatcher(); | ||
| auto impl = std::make_shared<ReadRange>(10000, 30); | ||
| auto reader = MakeTracingObjectDescriptorReader(impl); | ||
| auto reader = | ||
|
Contributor
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. Can we test the attribute that we just set? |
||
| MakeTracingObjectDescriptorReader(impl, /*cache_status=*/"TEST"); | ||
|
|
||
| impl->OnFinish(PermanentError()); | ||
|
|
||
|
|
||
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.
Generally, we follow the naming convention with
.or with-.So, maybe something like
gl-cpp.open.ranges.size?