Skip to content

Add mem_total_bytes metric to Memory instrumentation

Matthias Käppler requested to merge mk-compute-total-mem-use into master

What does this MR do?

This tracks the total amount of bytes allocated during a web transaction by taking into account both malloc'ed objects as well as heap slots occupied by newly allocated objects.

This is useful to get an idea of how much memory can be allotted to a given request overall, even when no extra mallocs were required. We will use this in the new memory gauge in the Performance Bar in !61332 (merged)

Not user-facing since this will merely appear in logs for now.

Screenshots (strongly suggested)

Grabbing a log line emitted via log/development_json.log:

{
  "method": "GET",
  "path": "/",
  "format": "html",
  "controller": "RootController",
  "action": "index",
  "status": 200,
  "time": "2021-05-14T13:44:40.707Z",
  "params": [],
  "remote_ip": "172.17.0.1",
  "user_id": 1,
  "username": "root",
  "ua": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:88.0) Gecko/20100101 Firefox/88.0",
  "correlation_id": "01F5NHY08WH39C8QT35VXBMW60",
  "meta.user": "root",
  "meta.caller_id": "RootController#index",
  "meta.remote_ip": "172.17.0.1",
  "meta.feature_category": "projects",
  "meta.client_id": "user/1",
  "gitaly_calls": 4,
  "gitaly_duration_s": 0.088498,
  "db_count": 74,
  "db_write_count": 3,
  "db_cached_count": 11,
  "cpu_s": 13.977864,
  "mem_objects": 6403300,
  "mem_bytes": 492366475,
  "mem_mallocs": 1732162,
  "mem_total_bytes": 748498475,
  "queue_duration_s": 0.84261,
  "db_duration_s": 0.44699,
  "view_duration_s": 5.78625,
  "duration_s": 7.45504
}

Sanity check:

[15:47:08] work/gl-gck::master ✔ echo '6403300 * 40 + 492366475' | bc

748498475

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Edited by Matthias Käppler

Merge request reports