Skip to content

Batch Bloom filter probes for aligned metadata cache misses - #19509

Closed
ColinLeeo wants to merge 3 commits into
apache:masterfrom
ColinLeeo:perf/batch-bloom-metadata-cache
Closed

ColinLeeo wants to merge 3 commits into
apache:masterfrom
ColinLeeo:perf/batch-bloom-metadata-cache

Conversation

@ColinLeeo

@ColinLeeo ColinLeeo commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Superseded by #19514 for same-repository CI. Please continue the review there.

Summary

Use TsFile's batch Bloom filter API for aligned metadata cache misses. This builds on the selective metadata read in IoTDB #19198 and uses the in-place Bloom filter API in TsFile #1181, built on TsFile #1143.

The time-column check can still rule out a device before looking up its value columns. Both ordinary aligned scans and external TsFile scans submit the remaining value columns in one batch per file. TsFile removes definite misses from the pending set in place. IoTDB uses the callback to record a null for each missing column. Only the possible matches reach the metadata reader.

Example

Suppose an aligned query requests temperature and pressure on a cold cache. The file contains temperature, and its Bloom filter rules out pressure. Previously IoTDB probed the two full paths individually after the time-column check. It now makes one batch call with both names. The reader loads the time column and temperature. The result still has a null entry for pressure, and a later query can probe it again without occupying a negative cache entry.

Verification

  • Ran TimeSeriesMetadataCacheTest, AlignedSeriesScanBatchTest, and ReadPointAlignedCrossCompactionTest against 2.5.1-261203-SNAPSHOT. 39 tests passed, and one existing performance test was skipped.
  • Repeated all three tests in a Maven repository without a locally installed copy of this snapshot. Maven downloaded build 20261203.024354-2 from Apache snapshots. The published JAR contains the same 1,060 class files, byte for byte, as the tested build of TsFile PR commit c71af5509.
  • Compiled the full reactor with the English and Chinese locales.
  • Built the standard and Edge distributions and verified the embedded TsFile JAR in both ZIPs.

iterator.remove();
// The device gate already checked the time column. Keep a stable order for the result bits.
List<String> measurements = new ArrayList<>(pending);
measurements.remove("");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

list.remove? costly....

}
iterator.remove();
// The device gate already checked the time column. Keep a stable order for the result bits.
List<String> measurements = new ArrayList<>(pending);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no need to do this converting.

if (measurements.isEmpty()) {
return;
}
BitSet matches = bloomFilter.mightContainBatch(device, measurements);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

bloomFilter should offer a method removeNotExistingMeasurements(IDeviceID, Set, BiConsumer<IDeviceID, String>), then what you need is just call it:

bloomFilter.removeNotExistingMeasurements(device, pending, new NonExistMeasurementConsumer(tsFileID, debug, result))

private static class NonExistMeasurementConsumer implements BiConsumer<IDeviceID, String> {
    private final TsFileID tsFileID;
    
    private final Map<String, TimeseriesMetadata> result;
    private final boolean debug;

    public NonExistMeasurementConsumer(TsFileID tsFileID, boolean debug, Map<String, TimeseriesMetadata> result) {
      this.tsFileID = tsFileID;
      this.debug = debug;
      this.result = result;
    }

    @Override
    public void accept(IDeviceID deviceID, String nonExistMeasurement) {
      if (debug) {
        DEBUG_LOGGER.info(
            StorageEngineMessages.TS_METADATA_FILTERED_BY_BLOOM_FILTER,
            new TimeSeriesMetadataCacheKey(tsFileID, deviceID, nonExistMeasurement));
      }
      result.put(nonExistMeasurement, null);
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants