Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSDB numeric compression #92045

Conversation

salvatore-campagna
Copy link
Contributor

@salvatore-campagna salvatore-campagna commented Dec 1, 2022

This PR introduces a new doc values format meant to be used by TSDB. It
provides compression using delta encoding, gcd encoding and bit-packing
encoding. The expectation is that such encodings work well for numeric
fields whose values are monotonically increasing, like the timestamp field
and counter metric fields.

This doc values format is meant to be used for tsdb. It provides
compression using delta encoding, gcd encoding and bit-packing
encoding. The expectation is that such encoding works well for
fields whose values are monotonically increasing, like the timestamp
field and counter metric fields.
This makes it easier to experiment with different encoding block sizes,
and maybe also making the block size a configurable parameter.
@elasticsearchmachine elasticsearchmachine added v8.7.0 needs:triage Requires assignment of a team area label labels Dec 1, 2022
@salvatore-campagna salvatore-campagna self-assigned this Dec 1, 2022
@salvatore-campagna salvatore-campagna added :StorageEngine/TSDB You know, for Metrics >feature and removed needs:triage Requires assignment of a team area label labels Dec 1, 2022
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Dec 1, 2022
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytics-geo (Team:Analytics)

@elasticsearchmachine
Copy link
Collaborator

Hi @salvatore-campagna, I've created a changelog YAML for you.

@nik9000
Copy link
Member

nik9000 commented Dec 1, 2022

Neat! I'm super curious what this does to our benchmarks - the size, and, a little, the speed.


@Override
public void addNumericField(FieldInfo field, DocValuesProducer valuesProducer) throws IOException {
meta.writeInt(field.number);
Copy link
Contributor Author

@salvatore-campagna salvatore-campagna Dec 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: here I am not writing the type of field (NUMERIC) because this only works for numeric fields and I spare some space not writing a value that would always be the same. I am wondering, anyway, if not writing this might have an impact in terms of BWC in case we later introduce compression for other fields.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest keeping it: we are talking about a single integer per segment per field, so the impact on space efficiency is null, and we could more easily add support for other types of doc values later on.

@weizijun
Copy link
Contributor

weizijun commented Dec 2, 2022

Could you consider adding zstd compression lib to libs modules like lz4 lib. The zstd compressed radio is much larger than lz4 in the tsdb metrics.

@salvatore-campagna
Copy link
Contributor Author

salvatore-campagna commented Dec 2, 2022

Could you consider adding zstd compression lib to libs modules like lz4 lib. The zstd compressed radio is much larger than lz4 in the tsdb metrics.

HI @weizijun, the idea is to start with this compression because it is what we believe is more effective for numeric fields. zstd and lz4 are more generic compression algorithms which we expected not to be that effective. We might consider those for the future anyway, maybe for other fields.

@jpountz
Copy link
Contributor

jpountz commented Dec 7, 2022

@rockdaboot I think it will make sense to expand this to non-TSDB data streams at some point too. I'm not sure exactly how exactly, whether it will be enabled in a selective way, e.g. only on fields that are part of the index sort, or across all fields. But I can certainly imagine this being useful outside of TSDB. The main question I'm curious of which we haven't evaluated yet is how this change affects query performance.

@rockdaboot
Copy link
Contributor

@jpountz

I'm not sure exactly how exactly, whether it will be enabled in a selective way, e.g. only on fields that are part of the index sort, or across all fields.

Just from my perspective, I'd like to see the selective way, e.g. an "encoding" property in the field mapping, with a good default.
It allows to manually make trade-offs between performance and storage costs (e.g. less performance with less storage), based on data not available to an ES' automatic decision algorithms.
Also, the developer may know the data better than an algorithm and is able to make the encoding decision not only better, but also the automatic "guess" step can be short-circuited to gain performance. With more encodings (hopefully) coming, which should be stackable, it's even harder to automatically find the best combination (e.g. thinking of "encoding": "doubledelta,zstd" or "encoding": "gorilla,lz4".

Anyway, if you open a discussion/issue around non-TSDB field encodings, please cc me 😃

@salvatore-campagna
Copy link
Contributor Author

@rockdaboot I think it will make sense to expand this to non-TSDB data streams at some point too. I'm not sure exactly how exactly, whether it will be enabled in a selective way, e.g. only on fields that are part of the index sort, or across all fields. But I can certainly imagine this being useful outside of TSDB. The main question I'm curious of which we haven't evaluated yet is how this change affects query performance.

Is there any reason why we should not have a way to define the encoding per each field with an additional mapping parameter?

Something like

mappings: {
   properties: {
      age: {
          type: integer,
          encoding: delta
     }
   }
}

@martijnvg
Copy link
Member

We ran the benchmark gain based on the latest changes. The baseline is the same as yesterday's benchmark run. This is a filtered result just showing the difference in size of doc values fields:

|                                                 Heap used for doc values |                         |     0           |     0           |     0       |     MB |    0.00% |
|                  tsdb kubernetes.event.metadata.generate_name doc values |                         |    16.7568      |    16.7568      |     0       |     kB |    0.00% |
|                tsdb kubernetes.labels.beta_kubernetes_io/arch doc values |                         |     8.43359     |     8.43359     |     0       |     kB |    0.00% |
|                  tsdb kubernetes.labels.beta_kubernetes_io/os doc values |                         |     8.43359     |     8.43359     |     0       |     kB |    0.00% |
|                     tsdb kubernetes.labels.kubernetes_io/arch doc values |                         |     8.43359     |     8.43359     |     0       |     kB |    0.00% |
|                       tsdb kubernetes.labels.kubernetes_io/os doc values |                         |     8.43359     |     8.43359     |     0       |     kB |    0.00% |
|       tsdb kubernetes.labels.beta_kubernetes_io/instance-type doc values |                         |    11.1992      |    11.1992      |     0       |     kB |    0.00% |
|           tsdb kubernetes.labels.app_kubernetes_io/managed-by doc values |                         |    88.0947      |    88.0947      |     0       |     kB |    0.00% |
|                          tsdb kubernetes.labels.helm_sh/chart doc values |                         |    92.3643      |    92.3643      |     0       |     kB |    0.00% |
|            tsdb kubernetes.labels.app_kubernetes_io/component doc values |                         |    96.8818      |    96.8818      |     0       |     kB |    0.00% |
|                     tsdb kubernetes.labels.io_kompose_service doc values |                         |   100.159       |   100.159       |     0       |     kB |    0.00% |
|                                   tsdb kubernetes.labels.name doc values |                         |   113.141       |   113.141       |     0       |     kB |    0.00% |
|                     tsdb kubernetes.node.status.unschedulable doc values |                         |   115.678       |   115.678       |     0       |     kB |    0.00% |
|                             tsdb kubernetes.node.status.ready doc values |                         |   116.6         |   116.6         |     0       |     kB |    0.00% |
|                                    tsdb kubernetes.event.type doc values |                         |   105.659       |   105.659       |     0       |     kB |    0.00% |
|                    tsdb kubernetes.node.cpu.allocatable.cores doc values |                         |   116.577       |   116.577       |     0       |     kB |    0.00% |
|                    tsdb kubernetes.node.pod.allocatable.total doc values |                         |   115.678       |   115.678       |     0       |     kB |    0.00% |
|                       tsdb kubernetes.node.pod.capacity.total doc values |                         |   115.678       |   115.678       |     0       |     kB |    0.00% |
|                        tsdb kubernetes.node.fs.capacity.bytes doc values |                         |   115.678       |   115.678       |     0       |     kB |    0.00% |
|                          tsdb kubernetes.node.fs.inodes.count doc values |                         |   115.678       |   115.678       |     0       |     kB |    0.00% |
|           tsdb kubernetes.node.runtime.imagefs.capacity.bytes doc values |                         |   115.678       |   115.678       |     0       |     kB |    0.00% |
|                       tsdb kubernetes.node.cpu.capacity.cores doc values |                         |   116.577       |   116.577       |     0       |     kB |    0.00% |
|                        tsdb kubernetes.node.network.rx.errors doc values |                         |   115.678       |   119.016       |     3.33789 |     kB |   +2.89% |
|                        tsdb kubernetes.node.network.tx.errors doc values |                         |   115.678       |   119.016       |     3.33789 |     kB |   +2.89% |
|                   tsdb kubernetes.node.memory.majorpagefaults doc values |                         |   155.599       |   129.222       |   -26.377   |     kB |  -16.95% |
|                 tsdb kubernetes.node.memory.allocatable.bytes doc values |                         |   325.465       |   325.465       |     0       |     kB |    0.00% |
|                    tsdb kubernetes.node.memory.capacity.bytes doc values |                         |   325.465       |   325.465       |     0       |     kB |    0.00% |
|             tsdb kubernetes.event.involved_object.api_version doc values |                         |   372.345       |   372.345       |     0       |     kB |    0.00% |
|                    tsdb kubernetes.event.involved_object.kind doc values |                         |   372.399       |   372.399       |     0       |     kB |    0.00% |
|                 tsdb kubernetes.labels.kubernetes_io/hostname doc values |                         |   558.354       |   558.354       |     0       |     kB |    0.00% |
|                               tsdb kubernetes.node.start_time doc values |                         |   542.827       |   542.827       |     0       |     kB |    0.00% |
|               tsdb kubernetes.node.runtime.imagefs.used.bytes doc values |                         |   542.827       |   542.827       |     0       |     kB |    0.00% |
|                   tsdb kubernetes.container.logs.inodes.count doc values |                         |   525.547       |   525.547       |     0       |     kB |    0.00% |
|                 tsdb kubernetes.container.logs.capacity.bytes doc values |                         |   525.547       |   525.547       |     0       |     kB |    0.00% |
|               tsdb kubernetes.container.rootfs.capacity.bytes doc values |                         |   525.547       |   525.547       |     0       |     kB |    0.00% |
|                                tsdb kubernetes.labels.k8s-app doc values |                         |   638.458       |   638.458       |     0       |     kB |    0.00% |
|                               tsdb kubernetes.labels.heritage doc values |                         |   687.157       |   687.157       |     0       |     kB |    0.00% |
|                      tsdb kubernetes.event.metadata.namespace doc values |                         |   727.936       |   727.936       |     0       |     kB |    0.00% |
|                              tsdb kubernetes.system.container doc values |                         |   877.309       |   877.309       |     0       |     kB |    0.00% |
|                                            tsdb agent.version doc values |                         |     6           |     6           |     0       |  bytes |    0.00% |
|                                              tsdb ecs.version doc values |                         |     6           |     6           |     0       |  bytes |    0.00% |
|                                               tsdb agent.type doc values |                         |    11           |    11           |     0       |  bytes |    0.00% |
|                                             tsdb event.module doc values |                         |    11           |    11           |     0       |  bytes |    0.00% |
|                                             tsdb service.type doc values |                         |    11           |    11           |     0       |  bytes |    0.00% |
|                                           tsdb fields.cluster doc values |                         |    13           |    13           |     0       |  bytes |    0.00% |
|                                  tsdb kubernetes.labels.chart doc values |                         |   994.973       |   994.973       |     0       |     kB |    0.00% |
|                                  tsdb kubernetes.event.reason doc values |                         |   728.374       |   728.374       |     0       |     kB |    0.00% |
|                                   tsdb kubernetes.event.count doc values |                         |  1162.98        |    93.209       | -1069.77    |     kB |  -91.99% |
|                 tsdb kubernetes.system.memory.majorpagefaults doc values |                         |  1369.29        |   594.549       |  -774.746   |     kB |  -56.58% |
|                          tsdb kubernetes.pod.status.scheduled doc values |                         |     1.56079     |     1.56079     |     0       |     MB |    0.00% |
|             tsdb kubernetes.labels.app_kubernetes_io/instance doc values |                         |     1.64294     |     1.64294     |     0       |     MB |    0.00% |
|                 tsdb kubernetes.labels.app_kubernetes_io/name doc values |                         |     1.66637     |     1.66637     |     0       |     MB |    0.00% |
|                           tsdb kubernetes.node.fs.inodes.used doc values |                         |     1.36438     |     1.36438     |     0       |     MB |    0.00% |
|                           tsdb kubernetes.node.fs.inodes.free doc values |                         |     1.36438     |     1.36438     |     0       |     MB |    0.00% |
|                             tsdb kubernetes.system.start_time doc values |                         |     1.79527     |     1.79527     |     0       |     MB |    0.00% |
|                                   tsdb kubernetes.labels.tier doc values |                         |     1.90071     |     1.90071     |     0       |     MB |    0.00% |
|                         tsdb kubernetes.pod.network.rx.errors doc values |                         |     1.46605     |     1.49925     |     0.03321 |     MB |   +2.27% |
|                         tsdb kubernetes.pod.network.tx.errors doc values |                         |     1.46605     |     1.49925     |     0.03321 |     MB |   +2.27% |
|                              tsdb kubernetes.statefulset.name doc values |                         |     2.00588     |     2.00588     |     0       |     MB |    0.00% |
|                              tsdb kubernetes.labels.component doc values |                         |     1.99298     |     1.99298     |     0       |     MB |    0.00% |
|                        tsdb kubernetes.node.memory.pagefaults doc values |                         |  1397.13        |   256.256       | -1140.87    |     kB |  -81.66% |
|        tsdb kubernetes.event.involved_object.resource_version doc values |                         |     1.56013     |     1.56013     |     0       |     MB |    0.00% |
|                    tsdb kubernetes.event.involved_object.name doc values |                         |     1.46456     |     1.46456     |     0       |     MB |    0.00% |
|                              tsdb kubernetes.pod.status.ready doc values |                         |     2.09304     |     2.09304     |     0       |     MB |    0.00% |
|     tsdb kubernetes.labels.statefulset_kubernetes_io/pod-name doc values |                         |     2.31645     |     2.31645     |     0       |     MB |    0.00% |
|              tsdb kubernetes.container.memory.majorpagefaults doc values |                         |  2109.35        |   663.929       | -1445.42    |     kB |  -68.52% |
|                              tsdb kubernetes.pod.status.phase doc values |                         |     2.45245     |     2.45245     |     0       |     MB |    0.00% |
|                                   tsdb kubernetes.pod.host_ip doc values |                         |     2.0283      |     2.0283      |     0       |     MB |    0.00% |
|                                        tsdb container.runtime doc values |                         |    35.5518      |    35.5518      |     0       |     kB |    0.00% |
|                           tsdb kubernetes.event.metadata.name doc values |                         |     1.9104      |     1.9104      |     0       |     MB |    0.00% |
|               tsdb kubernetes.event.metadata.resource_version doc values |                         |     1.88133     |     1.88133     |     0       |     MB |    0.00% |
|                      tsdb kubernetes.event.metadata.self_link doc values |                         |     1.91862     |     1.91862     |     0       |     MB |    0.00% |
|                       tsdb kubernetes.node.fs.available.bytes doc values |                         |     1.57295     |     1.57295     |     0       |     MB |    0.00% |
|          tsdb kubernetes.node.runtime.imagefs.available.bytes doc values |                         |     1.57295     |     1.57295     |     0       |     MB |    0.00% |
|                            tsdb kubernetes.node.fs.used.bytes doc values |                         |     1.57295     |     1.57295     |     0       |     MB |    0.00% |
|                  tsdb kubernetes.node.memory.workingset.bytes doc values |                         |     1.36438     |     1.36438     |     0       |     MB |    0.00% |
|                         tsdb kubernetes.node.memory.rss.bytes doc values |                         |     1.36438     |     1.36438     |     0       |     MB |    0.00% |
|                       tsdb kubernetes.node.memory.usage.bytes doc values |                         |     1.36438     |     1.36438     |     0       |     MB |    0.00% |
|                   tsdb kubernetes.node.memory.available.bytes doc values |                         |     1.57295     |     1.57295     |     0       |     MB |    0.00% |
|              tsdb kubernetes.event.metadata.timestamp.created doc values |                         |     1.80374     |     1.80374     |     0       |     MB |    0.00% |
|               tsdb kubernetes.event.timestamp.last_occurrence doc values |                         |     1.75242     |     1.75242     |     0       |     MB |    0.00% |
|                  tsdb kubernetes.container.rootfs.inodes.used doc values |                         |     3.14363     |     3.14363     |     0       |     MB |    0.00% |
|              tsdb kubernetes.event.timestamp.first_occurrence doc values |                         |     1.96778     |     1.96778     |     0       |     MB |    0.00% |
|                      tsdb kubernetes.node.cpu.usage.nanocores doc values |                         |     2.19866     |     2.19866     |     0       |     MB |    0.00% |
|                  tsdb kubernetes.pod.memory.major_page_faults doc values |                         |     3.50078     |     1.60505     |    -1.89572 |     MB |  -54.15% |
|                     tsdb kubernetes.event.involved_object.uid doc values |                         |     2.41599     |     2.41599     |     0       |     MB |    0.00% |
|                tsdb kubernetes.labels.pod-template-generation doc values |                         |     4.31266     |     4.31266     |     0       |     MB |    0.00% |
|                         tsdb kubernetes.node.network.tx.bytes doc values |                         |     2.6158      |     2.6158      |     0       |     MB |    0.00% |
|                         tsdb kubernetes.node.network.rx.bytes doc values |                         |     2.6158      |     2.6158      |     0       |     MB |    0.00% |
|               tsdb kubernetes.container.memory.usage.node.pct doc values |                         |     3.76555     |     3.76555     |     0       |     MB |    0.00% |
|                        tsdb kubernetes.node.cpu.usage.core.ns doc values |                         |     3.03293     |     3.03293     |     0       |     MB |    0.00% |
|                                tsdb kubernetes.labels.logtype doc values |                         |     5.81766     |     5.81766     |     0       |     MB |    0.00% |
|                         tsdb kubernetes.volume.fs.inodes.used doc values |                         |     5.22743     |     5.22743     |     0       |     MB |    0.00% |
|                                          tsdb service.address doc values |                         |     1.76394     |     1.76394     |     0       |     MB |    0.00% |
|                                            tsdb event.dataset doc values |                         |   338.656       |   338.656       |     0       |     kB |    0.00% |
|                      tsdb kubernetes.system.memory.pagefaults doc values |                         |     4.92384     |     1.32168     |    -3.60216 |     MB |  -73.16% |
|                     tsdb kubernetes.pod.memory.usage.node.pct doc values |                         |     5.2551      |     5.2551      |     0       |     MB |    0.00% |
|                   tsdb kubernetes.container.rootfs.used.bytes doc values |                         |     5.16927     |     5.16927     |     0       |     MB |    0.00% |
|                          tsdb kubernetes.volume.fs.used.bytes doc values |                         |     5.77369     |     5.77369     |     0       |     MB |    0.00% |
|                         tsdb kubernetes.labels.github_account doc values |                         |     6.59348     |     6.59348     |     0       |     MB |    0.00% |
|                       tsdb kubernetes.system.memory.rss.bytes doc values |                         |     3.90072     |     3.90072     |     0       |     MB |    0.00% |
|                tsdb kubernetes.system.memory.workingset.bytes doc values |                         |     3.96322     |     3.96322     |     0       |     MB |    0.00% |
|               tsdb kubernetes.labels.controller-revision-hash doc values |                         |     8.20422     |     8.20422     |     0       |     MB |    0.00% |
|                  tsdb kubernetes.container.cpu.usage.node.pct doc values |                         |     4.65845     |     4.65845     |     0       |     MB |    0.00% |
|                            tsdb kubernetes.event.metadata.uid doc values |                         |     5.37335     |     5.37335     |     0       |     MB |    0.00% |
|                     tsdb kubernetes.system.memory.usage.bytes doc values |                         |     4.29813     |     4.29813     |     0       |     MB |    0.00% |
|                        tsdb kubernetes.container.status.phase doc values |                         |     4.40022     |     4.40022     |     0       |     MB |    0.00% |
|                                   tsdb kubernetes.volume.name doc values |                         |     9.33376     |     9.33376     |     0       |     MB |    0.00% |
|                        tsdb kubernetes.volume.fs.inodes.count doc values |                         |     9.33353     |     9.33353     |     0       |     MB |    0.00% |
|                      tsdb kubernetes.volume.fs.capacity.bytes doc values |                         |     9.33353     |     9.33353     |     0       |     MB |    0.00% |
|                        tsdb kubernetes.pod.cpu.usage.node.pct doc values |                         |     5.71234     |     5.71234     |     0       |     MB |    0.00% |
|                                           tsdb metricset.name doc values |                         |     4.08741     |     4.08741     |     0       |     MB |    0.00% |
|                                tsdb kubernetes.labels.release doc values |                         |     9.83968     |     9.83968     |     0       |     MB |    0.00% |
|                    tsdb kubernetes.system.cpu.usage.nanocores doc values |                         |     5.59806     |     5.59806     |     0       |     MB |    0.00% |
|              tsdb kubernetes.container.memory.usage.limit.pct doc values |                         |     6.25022     |     6.25022     |     0       |     MB |    0.00% |
|                    tsdb kubernetes.pod.memory.usage.limit.pct doc values |                         |     7.74271     |     7.74271     |     0       |     MB |    0.00% |
|                       tsdb kubernetes.pod.cpu.usage.limit.pct doc values |                         |     7.24244     |     7.24244     |     0       |     MB |    0.00% |
|                 tsdb kubernetes.container.cpu.usage.limit.pct doc values |                         |     6.26976     |     6.26976     |     0       |     MB |    0.00% |
|                                tsdb kubernetes.pod.start_time doc values |                         |    13.6329      |    13.6329      |     0       |     MB |    0.00% |
|                          tsdb kubernetes.container.start_time doc values |                         |    13.1514      |    13.1514      |     0       |     MB |    0.00% |
|                               tsdb kubernetes.replicaset.name doc values |                         |    13.1996      |    13.1996      |     0       |     MB |    0.00% |
|                      tsdb kubernetes.labels.pod-template-hash doc values |                         |    13.1997      |    13.1997      |     0       |     MB |    0.00% |
|                                        tsdb kubernetes.pod.ip doc values |                         |    11.4339      |    11.4339      |     0       |     MB |    0.00% |
|                        tsdb kubernetes.container.status.ready doc values |                         |    12.0814      |    12.0814      |     0       |     MB |    0.00% |
|                       tsdb kubernetes.container.status.reason doc values |                         |    14.7286      |    14.7286      |     0       |     MB |    0.00% |
|                      tsdb kubernetes.system.cpu.usage.core.ns doc values |                         |     9.30381     |     9.30381     |     0       |     MB |    0.00% |
|                     tsdb kubernetes.container.logs.used.bytes doc values |                         |     7.08308     |     7.08308     |     0       |     MB |    0.00% |
|              tsdb kubernetes.container.memory.available.bytes doc values |                         |     9.01515     |     9.01515     |     0       |     MB |    0.00% |
|                    tsdb kubernetes.pod.memory.available.bytes doc values |                         |    11.6769      |    11.6769      |     0       |     MB |    0.00% |
|                          tsdb kubernetes.pod.memory.rss.bytes doc values |                         |    11.4734      |    11.4734      |     0       |     MB |    0.00% |
|                  tsdb kubernetes.pod.memory.working_set.bytes doc values |                         |    11.1999      |    11.1999      |     0       |     MB |    0.00% |
|                        tsdb kubernetes.pod.memory.usage.bytes doc values |                         |    11.6375      |    11.6375      |     0       |     MB |    0.00% |
|                    tsdb kubernetes.container.memory.rss.bytes doc values |                         |    10.4428      |    10.4428      |     0       |     MB |    0.00% |
|             tsdb kubernetes.container.memory.workingset.bytes doc values |                         |    10.4506      |    10.4506      |     0       |     MB |    0.00% |
|                  tsdb kubernetes.container.memory.usage.bytes doc values |                         |    10.8881      |    10.8881      |     0       |     MB |    0.00% |
|                    tsdb kubernetes.container.logs.inodes.free doc values |                         |    15.2721      |    15.2721      |     0       |     MB |    0.00% |
|                    tsdb kubernetes.container.logs.inodes.used doc values |                         |    15.2721      |    15.2721      |     0       |     MB |    0.00% |
|                     tsdb kubernetes.container.status.restarts doc values |                         |    21.7051      |    10.5076      |   -11.1974  |     MB |  -51.59% |
|                         tsdb kubernetes.volume.fs.inodes.free doc values |                         |    23.8724      |    23.8724      |     0       |     MB |    0.00% |
|                                    tsdb kubernetes.labels.app doc values |                         |    23.9969      |    23.9969      |     0       |     MB |    0.00% |
|                        tsdb kubernetes.pod.memory.page_faults doc values |                         |    14.2856      |     4.79175     |    -9.49385 |     MB |  -66.46% |
|                     tsdb kubernetes.volume.fs.available.bytes doc values |                         |    25.5997      |    25.5997      |     0       |     MB |    0.00% |
|                                                    tsdb _tsid doc values |                         |    30.4379      |    30.4379      |     0       |     MB |    0.00% |
|                   tsdb kubernetes.container.memory.pagefaults doc values |                         |    12.96        |     3.82234     |    -9.13769 |     MB |  -70.51% |
|                                  tsdb kubernetes.container.id doc values |                         |    17.4829      |    17.4829      |     0       |     MB |    0.00% |
|                                             tsdb container.id doc values |                         |    17.4799      |    17.4799      |     0       |     MB |    0.00% |
|                                         tsdb metricset.period doc values |                         |    10.7645      |    10.7645      |     0       |     MB |    0.00% |
|                       tsdb kubernetes.pod.cpu.usage.nanocores doc values |                         |    17.3961      |    17.3961      |     0       |     MB |    0.00% |
|                                tsdb kubernetes.container.name doc values |                         |    29.4211      |    29.4211      |     0       |     MB |    0.00% |
|                               tsdb kubernetes.container.image doc values |                         |    32.3011      |    32.3011      |     0       |     MB |    0.00% |
|                tsdb kubernetes.container.logs.available.bytes doc values |                         |    17.7354      |    17.7354      |     0       |     MB |    0.00% |
|              tsdb kubernetes.container.rootfs.available.bytes doc values |                         |    17.7354      |    17.7354      |     0       |     MB |    0.00% |
|                                     tsdb kubernetes.node.name doc values |                         |    31.6867      |    31.6867      |     0       |     MB |    0.00% |
|                 tsdb kubernetes.container.cpu.usage.nanocores doc values |                         |    17.7645      |    17.7645      |     0       |     MB |    0.00% |
|                          tsdb kubernetes.pod.network.tx.bytes doc values |                         |    24.1309      |    11.3976      |   -12.7332  |     MB |  -52.77% |
|                          tsdb kubernetes.pod.network.rx.bytes doc values |                         |    24.4199      |    11.7271      |   -12.6929  |     MB |  -51.98% |
|                                     tsdb kubernetes.namespace doc values |                         |    43.9807      |    43.9807      |     0       |     MB |    0.00% |
|                               tsdb kubernetes.labels.job-name doc values |                         |    48.6838      |    48.6838      |     0       |     MB |    0.00% |
|                         tsdb kubernetes.labels.controller-uid doc values |                         |    50.7148      |    50.7148      |     0       |     MB |    0.00% |
|                   tsdb kubernetes.container.cpu.usage.core.ns doc values |                         |    29.6212      |    29.6212      |     0       |     MB |    0.00% |
|                     tsdb kubernetes.container.cpu.limit.cores doc values |                         |    63.2537      |    63.2537      |     0       |     MB |    0.00% |
|                  tsdb kubernetes.container.memory.limit.bytes doc values |                         |    66.3388      |    66.3388      |     0       |     MB |    0.00% |
|                tsdb kubernetes.container.memory.request.bytes doc values |                         |    68.0876      |    68.0876      |     0       |     MB |    0.00% |
|                   tsdb kubernetes.container.cpu.request.cores doc values |                         |    69.4779      |    69.4779      |     0       |     MB |    0.00% |
|                                         tsdb _recovery_source doc values |                         |   154.959       |   702.227       |   547.268   |     kB | +353.17% |
|                                       tsdb kubernetes.pod.uid doc values |                         |    78.6883      |    78.6883      |     0       |     MB |    0.00% |
|                                      tsdb kubernetes.pod.name doc values |                         |    93.626       |    93.626       |     0       |     MB |    0.00% |
|                                                 tsdb agent.id doc values |                         |    99.9378      |    99.9378      |     0       |     MB |    0.00% |
|                                           tsdb agent.hostname doc values |                         |   111.231       |   111.231       |     0       |     MB |    0.00% |
|                                                tsdb host.name doc values |                         |   111.231       |   111.231       |     0       |     MB |    0.00% |
|                                       tsdb agent.ephemeral_id doc values |                         |   111.235       |   111.235       |     0       |     MB |    0.00% |
|                                               tsdb @timestamp doc values |                         |   389.307       |   196.771       |  -192.536   |     MB |  -49.46% |
|                                                  tsdb _seq_no doc values |                         |   389.307       |   389.307       |     0       |     MB |    0.00% |
|                                           tsdb event.duration doc values |                         |   552.725       |   552.725       |     0       |     MB |    0.00% |

The _recovery_source doc values fields is now much larger, but I think that is noise. Also _recovery_source stored fields are much larger. I think the merge policy was unable to trigger the trimming of a larger part of the _recovery_source before the end of the benchmark compared to the baseline.

The tx/rx fields (for example kubernetes.pod.network.rx.errors field) now take slightly more disk space. But that is very minor and I don't think a blocker, since other fields take so much less space now. But it would be nice to see if this tiny negative effect can be avoided.

@jpountz
Copy link
Contributor

jpountz commented Dec 20, 2022

@martijnvg and I had a quick chat about disk usage with this new doc-values format. Quoting a comment I made earlier on this PR:

this format only optimizes for numbers of bits per value in [1:24], 32 and 64 while Lucene's default doc-values format optimizes for {1, 2, 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 56, 64}.

We should be able to guarantee that this format would never cause significant regressions regarding disk usage by updating DocValuesForUtil to also specialize for numbers of bits per value 28, 40, 48 and 56. This should help with slowly changing floating-point numbers such as gauges, and counter blocks that contain a reset.

@salvatore-campagna
Copy link
Contributor Author

@martijnvg and I had a quick chat about disk usage with this new doc-values format. Quoting a comment I made earlier on this PR:

this format only optimizes for numbers of bits per value in [1:24], 32 and 64 while Lucene's default doc-values format optimizes for {1, 2, 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 56, 64}.

We should be able to guarantee that this format would never cause significant regressions regarding disk usage by updating DocValuesForUtil to also specialize for numbers of bits per value 28, 40, 48 and 56. This should help with slowly changing floating-point numbers such as gauges, and counter blocks that contain a reset.

@jpountz do you have any pointer to where this is done in Lucene? I would like to have a look at it and understand how to adapt it also to 28, 40, 48 and 56.

@salvatore-campagna
Copy link
Contributor Author

salvatore-campagna commented Dec 23, 2022

@martijnvg and I had a quick chat about disk usage with this new doc-values format. Quoting a comment I made earlier on this PR:

this format only optimizes for numbers of bits per value in [1:24], 32 and 64 while Lucene's default doc-values format optimizes for {1, 2, 4, 8, 12, 16, 20, 24, 28, 32, 40, 48, 56, 64}.

We should be able to guarantee that this format would never cause significant regressions regarding disk usage by updating DocValuesForUtil to also specialize for numbers of bits per value 28, 40, 48 and 56. This should help with slowly changing floating-point numbers such as gauges, and counter blocks that contain a reset.

Ok I see this is used in Lucene to read/write postings lists in Lucene90PostingsReader/Lucene90PostingsWriter... but I don't see any specific optimization for 28, 40, 48 and 56.

@salvatore-campagna
Copy link
Contributor Author

salvatore-campagna commented Jan 5, 2023

I will put this DocValuesFormat behind a feature flag so to avoid releasing it without proper testing and add throughput benchmarks too.

@salvatore-campagna
Copy link
Contributor Author

I still need to add a benchmark.

Copy link
Member

@martijnvg martijnvg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍
I think the micro benchmarks can be added in a followup change.

area: TSDB
type: feature
issues: []
highlight:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before the FF date we need to check whether this codec is still behind a feature flag.
In order to avoid that we mention something in the changeling that is only usable via a feature flag.

@salvatore-campagna
Copy link
Contributor Author

@elasticsearchmachine run elasticsearch-ci/part-1 please

@salvatore-campagna
Copy link
Contributor Author

@martijnvg @jpountz I will merge this and add microbenchmarks in another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>feature >non-issue :StorageEngine/TSDB You know, for Metrics Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants