Closed Bug 1485313 Opened 6 years ago Closed 6 years ago

The HistogramInfo structure could be compacted

Categories

(Toolkit :: Telemetry, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
mozilla64
Tracking Status
firefox64 --- fixed

People

(Reporter: adrian17, Assigned: janerik)

References

Details

Attachments

(1 file)

This is the current definition of HistogramInfo:
https://searchfox.org/mozilla-central/source/toolkit/components/telemetry/TelemetryHistogram.cpp#131

struct HistogramInfo {
  uint32_t min;
  uint32_t max;
  uint32_t bucketCount;
  uint32_t histogramType;
  uint32_t name_offset;
  uint32_t expiration_offset;
  uint32_t dataset;
  uint32_t label_index;
  uint32_t label_count;
  uint32_t key_index;
  uint32_t key_count;
  RecordedProcessType record_in_processes; // enum : uint32_t
  bool keyed;
  SupportedProduct products; // enum : uint32_t
};

In x64, it takes 56 bytes. The array gHistogramInfos holds around 1800 entries - that's around 100kB in total. In fact, it seems to be the biggest single object reported by readelf on my libxul build.

Of these, it seems like some fields are bigger than necessary:
- the enums RecordedProcessType and SupportedProduct could probably fit in uint8_t,
- histogramType seems to be an enum with 6 values, so it could also fit in uint8_t,
- dataset seems to have only two possible values (optin/optout),
- label_index, key_index are indices into arrays with less than 2**16 elements.

With reducing the field size and some reordering it should be possible to reduce the gHistogramInfos array by 20kB or more.
Blocks: 1475556
Priority: -- → P3
Assignee: nobody → jrediger
Priority: P3 → P1
QA Contact: gfritzsche
I have no idea how I managed to put in a QA contact there, but I'm also not able to remove it again. Sorry about that.
This reduces the size of a HistogramInfo instance from 56 byte down to 40 bytes.
At currently ~1770 histogram that saves a total of 28,000 byte of static data.
QA Contact: gfritzsche
Pushed by jrediger@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/705896b42137
Compact HistogramInfo structure r=Dexter
https://hg.mozilla.org/mozilla-central/rev/705896b42137
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla64
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: