Closed Bug 1560049 Opened 6 years ago Closed 6 years ago

Timespan and TimingDistributions are fundamentally bugged: hashCode is not stable outside of obj lifetime

Categories

(Data Platform and Tools :: Glean: SDK, defect, P1)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: Dexter, Assigned: Dexter)

References

Details

(Whiteboard: [telemetry:mobilesdk:m7])

Attachments

(1 file)

Timespans and TiminigDistirbution are accepting an (id: Any) object to distinguish between running time measurements. However, this relies on hashCode to be stable after the lifetime of 'id', which is not guaranteed.

Luckily for us, no one is using TimingDistribution and Timespans for now (except Glean SDK internals with the 'baseline.duration' metric), so we could fix this with no repercussions in the wild.

The proposed solution:

  • have the 'timer.start()' method of both Timespan and TimingDistribution return an handler/integer;
  • have the caller manage that timer id and pass it to the 'stopAndSum' when required.

The id would just be a synchronized incremental integer, incremented on every start() call, on the TimingManager.

Priority: -- → P1
Whiteboard: [telemetry:mobilesdk:m7]
Assignee: nobody → alessio.placitelli
See Also: → 1556798
Attached file GitHub Pull Request
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED

For the future: some of our notes for the reworked API are here - https://docs.google.com/document/d/1x5Vm21K805eN9xyXHt5zvVkR9m-usOyGWQFJoumLE5w/edit

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: