@@ -42,6 +42,8 @@ StatusOr<std::string> MarshalHashtableProfile() {
4242
4343namespace debugging_internal {
4444
45+ static void DroppedHashtableSample () {}
46+
4547StatusOr<std::string> MarshalHashtableProfile (
4648 container_internal::HashtablezSampler& sampler, Time now) {
4749 static constexpr absl::string_view kDropFrames =
@@ -111,10 +113,18 @@ StatusOr<std::string> MarshalHashtableProfile(
111113 MakeSpan (info.stack , info.depth ), labels);
112114 });
113115
114- // TODO(b/262310142): Make this more structured data.
115- StringId comment_id =
116- builder.InternString (StrCat (" dropped_samples: " , dropped));
117- builder.set_comment_id (comment_id);
116+ if (dropped > 0 ) {
117+ // If we dropped samples, we don't have information for them, including
118+ // their sizes. The non-zero weight allows it to be noticed in the profile
119+ // and examined more closely.
120+ //
121+ // We compensate for the fixup done by AddSample by adjusting the address
122+ // here.
123+ const void * kFakeStack [] = {
124+ absl::bit_cast<void *>(
125+ reinterpret_cast <uintptr_t >(&DroppedHashtableSample)+1 )};
126+ builder.AddSample (static_cast <int64_t >(dropped), kFakeStack , {});
127+ }
118128 builder.AddCurrentMappings ();
119129 return std::move (builder).Emit ();
120130}
0 commit comments