tikv / tikv

Distributed transactional key-value database, originally created to complement TiDB
https://tikv.org
Apache License 2.0
15.27k stars 2.14k forks source link

In-Memory Engine: Do not filter every single key in buffer when writing #16475

Open afeinberg opened 9 months ago

afeinberg commented 9 months ago

Do not filter every single key in buffer when writing

Parent issue: https://github.com/tikv/tikv/issues/16141

Overview

Today ApplyContext has prepare_for and finish_for, two APIs that are called for the start and end of each region's apply work. We can do the check in the prepare_for function with region's range. The tricky part is how to carry the should_write_to_memory_engine boolean flag and let the WriteBatch be aware of it. We may have to introduce something like cache_enable() method into WriteBatch trait. And for each region's start, this cache_enable will be reset accordingly.

This could be an Option<bool>: when there's no context, we just use the current way that filters the keys one by one. This can be done later after the performance comparison.

Tasks

afeinberg commented 9 months ago

/assign @afeinberg