luci: Index | Files

package buildid

import ""

Package buildid provides the build id computation related functions.

Build key: Build keys are autogenerated, monotonically decreasing integers. That is, when sorted by key, new builds are first. Build has no parent.

Build id is a 64 bits integer. - 1 highest order bit is set to 0 to keep value positive. - 43 bits are 43 lower bits of bitwise-inverted time since

beginningOfTheWorld at 1ms resolution.
It is good for 2**43 / 365.3 / 24 / 60 / 60 / 1000 = 278 years
or 2010 + 278 = year 2288.

- 16 bits are set to a random value. Assuming an instance is internally

consistent with itself, it can ensure to not reuse the same 16 bits in two
consecutive requests and/or throttle itself to one request per
millisecond. Using random value reduces to 2**-15 the probability of
collision on exact same timestamp at 1ms resolution, so a maximum
theoretical rate of 65536000 requests/sec but an effective rate in the
range of ~64k qps without much transaction conflicts. We should be fine.

- 4 bits are 0. This is to represent the 'version' of the entity


The idea is taken from Swarming TaskRequest entity:;l=1380-1404


Package Files


func IdRange Uses

func IdRange(low, high time.Time) (int64, int64)

IdRange converts a creation time range to the build id range. Low/high bounds are inclusive/exclusive respectively for both time and id ranges.

func MayContainBuilds Uses

func MayContainBuilds(low, high time.Time) bool

MayContainBuilds returns true if the time range can possibly contain builds. Zero low/high value means no boundary for low/high.

Package buildid imports 1 packages (graph) and is imported by 1 packages. Updated 2020-08-15. Refresh now. Tools for package owners.