prometheus/storage/metric
Julius Volz 740d448983 Use custom timestamp type for sample timestamps and related code.
So far we've been using Go's native time.Time for anything related to sample
timestamps. Since the range of time.Time is much bigger than what we need, this
has created two problems:

- there could be time.Time values which were out of the range/precision of the
  time type that we persist to disk, therefore causing incorrectly ordered keys.
  One bug caused by this was:

  https://github.com/prometheus/prometheus/issues/367

  It would be good to use a timestamp type that's more closely aligned with
  what the underlying storage supports.

- sizeof(time.Time) is 192, while Prometheus should be ok with a single 64-bit
  Unix timestamp (possibly even a 32-bit one). Since we store samples in large
  numbers, this seriously affects memory usage. Furthermore, copying/working
  with the data will be faster if it's smaller.

*MEMORY USAGE RESULTS*
Initial memory usage comparisons for a running Prometheus with 1 timeseries and
100,000 samples show roughly a 13% decrease in total (VIRT) memory usage. In my
tests, this advantage for some reason decreased a bit the more samples the
timeseries had (to 5-7% for millions of samples). This I can't fully explain,
but perhaps garbage collection issues were involved.

*WHEN TO USE THE NEW TIMESTAMP TYPE*
The new clientmodel.Timestamp type should be used whenever time
calculations are either directly or indirectly related to sample
timestamps.

For example:
- the timestamp of a sample itself
- all kinds of watermarks
- anything that may become or is compared to a sample timestamp (like the timestamp
  passed into Target.Scrape()).

When to still use time.Time:
- for measuring durations/times not related to sample timestamps, like duration
  telemetry exporting, timers that indicate how frequently to execute some
  action, etc.

*NOTE ON OPERATOR OPTIMIZATION TESTS*
We don't use operator optimization code anymore, but it still lives in
the code as dead code. It still has tests, but I couldn't get all of them to
pass with the new timestamp format. I commented out the failing cases for now,
but we should probably remove the dead code soon. I just didn't want to do that
in the same change as this.

Change-Id: I821787414b0debe85c9fffaeb57abd453727af0f
2013-12-03 09:11:28 +01:00
..
.gitignore Spin up curator run in the tests. 2013-04-05 13:55:11 +02:00
compaction_regression_test.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
curator.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
dto.go WIP - Snapshot of Moving to Client Model. 2013-06-25 15:52:42 +02:00
end_to_end_test.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
freelist.go Update low-level i'faces to reflect wireformats. 2013-09-04 17:13:58 +02:00
helpers_test.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
index.go Include forgotten imports. 2013-08-14 18:52:55 +02:00
instrumentation.go Add notifications telemetry. 2013-07-31 12:40:56 +02:00
interface.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
interface_test.go Use LRU cache to avoid querying stale series. 2013-06-06 23:56:19 +02:00
labelpair.go WIP - Snapshot of Moving to Client Model. 2013-06-25 15:52:42 +02:00
labelpair_test.go WIP - Snapshot of Moving to Client Model. 2013-06-25 15:52:42 +02:00
leveldb.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
memory.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
memory_test.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
objective.go Update low-level i'faces to reflect wireformats. 2013-09-04 17:13:58 +02:00
operation.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
operation_test.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
processor.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
processor_test.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
regressions_test.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
rule_integration_test.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
sample.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
samplekey.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
scanjob.go WIP - Snapshot of Moving to Client Model. 2013-06-25 15:52:42 +02:00
stochastic_test.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
tiered.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
tiered_test.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
view.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
view_test.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00
watermark.go Use custom timestamp type for sample timestamps and related code. 2013-12-03 09:11:28 +01:00