Repository navigation
Conversation
Resolve an aligned device's metadata with one set-based reader call per (device, file) instead of one call per column. The cache checks the time column first, filters absent series with the BloomFilter before taking the device lock, and remembers read-confirmed absence. The single-column entry keeps its own path with sibling warming. TsFile side: apache/tsfile#1123 (merged as 0d89263e), consumed through the dated 2.5.1-261120-SNAPSHOT.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A device's
TimeseriesMetadatais stored in measurement leaf groups (up tomax_degree_of_index_nodeseries per group). Loading it column by column walks the device metadata index and deserializes the containing leaf group once per requested column, so a scan that selects almost all columns pays that traversal once per column, and every column absent from a file costs its own cache probe and BloomFilter check. In the motivating workload (one device with ~700 columns, ~20 written per day, 12 files) loading the metadata of one device across its files dominated the query.The TsFile side of this change is apache/tsfile#1123, now merged on
developas0d89263e; this PR pins the dated2.5.1-261120-SNAPSHOTcut from that commit.What changed
TsFile side (apache/tsfile#1123)
TsFileSequenceReader.readTimeseriesMetadataForMeasurements(device, offset, measurements, returnedMeasurements, mayExist, ignoreNotExistDevice, ioSizeRecorder)locates the device's measurement metadata index node (or reads the supplied offset for external TsFiles), routes each name to its floor child with a binary search over the node's children, and reads each visited internal node and each visited leaf group once. Chunk metadata is decoded only for the measurements the call returns.returnedMeasurementsmay be a superset ofmeasurements, which lets a single-column call warm its group siblings.mayExistis optional: a name is tested before it selects a group, so a group that only absent names point to is not read. It must have no false negatives; aBloomFilterqualifies.DataNode
TimeSeriesMetadataCache.getDeviceTimeseriesMetadatais now:count == 0, is answered with null and remembered with a negative cache entry, so a later query does not walk its leaf group again.Offset-addressed external TsFiles skip BloomFilter filtering, because their BloomFilter may not cover the series.
get()remains the single-column entry point used by tree-model scans. (Earlier revisions of this PR used a device-wide read gated by a 0.6 projection ratio; the selective reader replaces that design.)tsfile.versionmoves to2.5.1-261120-SNAPSHOT, cut from the mergeddevelop(apache/tsfile branchsnapshot/2.5.1-261120, squash commit0d89263e) and published to the Apache snapshots repository. It must be replaced by a released TsFile version before merge.Example
Table with 700 field columns; each of 12 TsFiles holds 20 of them (rotating);
SELECT *for one device:The per-column probe is the price of keeping negative entries bounded by the BloomFilter false-positive rate instead of one entry per absent column per file. A dense 700-column device adds the same probe per column but keeps the reads and bytes unchanged.
Benchmark
Measured on the latest revision with the same machine and TsFile snapshot for both variants, cold metadata cache unless noted; bytes and read counts come from
QueryStatistics. The base column was measured on master with the same harness. Each figure is the median of five timed rounds after warm-up; the dense cold case varies by up to about 20% between runs, so the table reports ranges.The sparse wide-table case that motivated the change is the main gain: cold 7.7–7.8 ms to 2.5–3.0 ms, warm 5.0–5.3 ms to 1.5–2.0 ms. The dense cold case varies by 15–20% between rounds on this machine (repeated runs of the previous revision show the same range, including a 30 ms outlier), so the table reports the observed range rather than a single sample; the bytes and read counts are identical across runs. The latest revision checks the aligned time column before the per-column cache pass and filters BloomFilter-excluded measurements before taking the device lock, so a warm sparse query no longer enters the locked recheck for columns that are absent from the file. Sparse cold still pays one BloomFilter probe per cache-missed column, which is what keeps negative entries bounded by the false-positive rate instead of one per absent column. The single-series
get()fast path answers a cache hit on the first LRU lookup, like master.Merge checklist
develop(squash commit0d89263e); the dated snapshot is cut from that commit.2.5.1-261120-SNAPSHOTinpom.xmlwith a released TsFile version before merge.Tests
TimeSeriesMetadataReadTestcovers batch vs per-measurement reads, absent names and devices, the offset-addressed variant, sibling warming, exact node/group read counts on an internal measurement index, aligned (time column) and table-model fixtures, and what an absent name costs with and withoutmayExist.TimeSeriesMetadataCacheTestadds "reader-confirmed absence is remembered, so the second query does not call the reader" and "a BloomFilter-excluded column is probed again instead of being remembered". It also covers cache hits, placeholders, BloomFilter exclusion and external TsFiles.AlignedSeriesScanBatchTest(dense, sparse and all-null projections end to end; the dense case asserts one reader call per file through a spied reader) andReadPointAlignedCrossCompactionTestcover the device-absent path.🤖 Generated with Claude Code