Skip to content

Commit e785661

Browse files
authored
Experiment with using tsdb doc values codec for _seq_no. (#133788)
Running metricsgenreceiver without this change: ``` "_seq_no": { "total": "369.9mb", "total_in_bytes": 387962443, "inverted_index": { "total": "0b", "total_in_bytes": 0 }, "stored_fields": "0b", "stored_fields_in_bytes": 0, "doc_values": "369.9mb", "doc_values_in_bytes": 387962443, "points": "0b", "points_in_bytes": 0, "norms": "0b", "norms_in_bytes": 0, "term_vectors": "0b", "term_vectors_in_bytes": 0, "knn_vectors": "0b", "knn_vectors_in_bytes": 0 } ``` and running metricsgenreceiver with this change: ``` "_seq_no": { "total": "212.3mb", "total_in_bytes": 222616293, "inverted_index": { "total": "0b", "total_in_bytes": 0 }, "stored_fields": "0b", "stored_fields_in_bytes": 0, "doc_values": "212.3mb", "doc_values_in_bytes": 222616293, "points": "0b", "points_in_bytes": 0, "norms": "0b", "norms_in_bytes": 0, "term_vectors": "0b", "term_vectors_in_bytes": 0, "knn_vectors": "0b", "knn_vectors_in_bytes": 0 } ``` metricsgenreceiver config: ``` receivers: metricsgen: start_now_minus: 72h interval: 5s interval_jitter_std_dev: 1ms real_time: false exit_after_end: true seed: 123 scenarios: - path: builtin/hostmetrics scale: 100 ```
1 parent a669863 commit e785661

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

server/src/main/java/org/elasticsearch/index/codec/PerFieldFormatSupplier.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.apache.lucene.codecs.lucene90.Lucene90DocValuesFormat;
1616
import org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsFormat;
1717
import org.elasticsearch.common.util.BigArrays;
18+
import org.elasticsearch.common.util.FeatureFlag;
1819
import org.elasticsearch.index.IndexMode;
1920
import org.elasticsearch.index.IndexSettings;
2021
import org.elasticsearch.index.IndexVersions;
@@ -25,6 +26,7 @@
2526
import org.elasticsearch.index.mapper.IdFieldMapper;
2627
import org.elasticsearch.index.mapper.Mapper;
2728
import org.elasticsearch.index.mapper.MapperService;
29+
import org.elasticsearch.index.mapper.SeqNoFieldMapper;
2830
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper;
2931

3032
/**
@@ -33,6 +35,8 @@
3335
*/
3436
public class PerFieldFormatSupplier {
3537

38+
private static final FeatureFlag SEQNO_FIELD_USE_TSDB_DOC_VALUES_FORMAT = new FeatureFlag("seqno_field_use_tsdb_doc_values_format");
39+
3640
private static final DocValuesFormat docValuesFormat = new Lucene90DocValuesFormat();
3741
private static final KnnVectorsFormat knnVectorsFormat = new Lucene99HnswVectorsFormat();
3842
private static final ES819TSDBDocValuesFormat tsdbDocValuesFormat = new ES819TSDBDocValuesFormat();
@@ -122,9 +126,13 @@ boolean useTSDBDocValuesFormat(final String field) {
122126
}
123127

124128
private boolean excludeFields(String fieldName) {
129+
// TODO: should we just allow all fields to use tsdb doc values codec?
125130
// Avoid using tsdb codec for fields like _seq_no, _primary_term.
126131
// But _tsid and _ts_routing_hash should always use the tsdb codec.
127-
return fieldName.startsWith("_") && fieldName.equals("_tsid") == false && fieldName.equals("_ts_routing_hash") == false;
132+
return fieldName.startsWith("_")
133+
&& fieldName.equals("_tsid") == false
134+
&& fieldName.equals("_ts_routing_hash") == false
135+
&& (SEQNO_FIELD_USE_TSDB_DOC_VALUES_FORMAT.isEnabled() && fieldName.equals(SeqNoFieldMapper.NAME) == false);
128136
}
129137

130138
private boolean isTimeSeriesModeIndex() {

0 commit comments

Comments
 (0)