Skip to content

Duplicated IOActivity-to-histogram mapping: GetExternalTableFileReadHistogram is a copy of GetFileReadHistograms #14935

Description

@damienmeur

Expected behavior

External table reads and regular SST reads map Env::IOActivity to the FILE_READ_* histograms through one shared helper, so the two paths cannot drift apart.

Actual behavior

The mapping exists twice in the tree:

  • GetFileReadHistogramsfile/random_access_file_reader.cc:26 (file-local inline, not declared in any header)
  • GetExternalTableFileReadHistogramtable/external_table.cc:26 (anonymous namespace), added by Wire external table reads into RocksDB metrics #14839 ("Wire external table reads into RocksDB metrics")

The two bodies are identical except for the signature line — presumably copied because the original is inline in a .cc and cannot be reused from another translation unit:

-inline Histograms GetFileReadHistograms(Statistics* stats,
-                                        Env::IOActivity io_activity) {
+Histograms GetExternalTableFileReadHistogram(Statistics* stats,
+                                             Env::IOActivity io_activity) {
   switch (io_activity) {
     ... (remaining 29 lines byte-identical) ...

Any future IOActivity case or stats-level condition added to one copy will silently miss the other: the missed path falls through to HISTOGRAM_ENUM_MAX and records nothing, so external-table reads would stop matching regular SST reads for that activity — the exact skew #14839 set out to prevent.

Steps to reproduce the behavior

Not a runtime bug yet; the copies are still in sync as of 5b1c3b3. Filing before they diverge.

Suggested fix: hoist GetFileReadHistograms into file/random_access_file_reader.h and call it from table/external_table.cc, deleting the copy. Happy to send a PR if that sounds right.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions