Skip to content

Commit 15e98fa

Browse files
committed
Revert "[Backport release-2.27] Improve readers by parallelizing I/O and compute operations (#5401) (#5451)"
This reverts commit 8652f02.
1 parent 73fb7ad commit 15e98fa

23 files changed

+143
-416
lines changed

test/src/unit-ReadCellSlabIter.cc

+1-4
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,7 @@ void set_result_tile_dim(
183183
std::nullopt,
184184
std::nullopt,
185185
std::nullopt);
186-
ResultTile::TileData tile_data{
187-
{nullptr, ThreadPool::SharedTask()},
188-
{nullptr, ThreadPool::SharedTask()},
189-
{nullptr, ThreadPool::SharedTask()}};
186+
ResultTile::TileData tile_data{nullptr, nullptr, nullptr};
190187
result_tile.init_coord_tile(
191188
constants::format_version,
192189
array_schema,

test/src/unit-cppapi-consolidation-with-timestamps.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ TEST_CASE_METHOD(
636636

637637
// Will only allow to load two tiles out of 3.
638638
Config cfg;
639-
cfg.set("sm.mem.total_budget", "50000");
639+
cfg.set("sm.mem.total_budget", "30000");
640640
cfg.set("sm.mem.reader.sparse_global_order.ratio_coords", "0.15");
641641
ctx_ = Context(cfg);
642642

@@ -685,7 +685,7 @@ TEST_CASE_METHOD(
685685

686686
// Will only allow to load two tiles out of 3.
687687
Config cfg;
688-
cfg.set("sm.mem.total_budget", "50000");
688+
cfg.set("sm.mem.total_budget", "30000");
689689
cfg.set("sm.mem.reader.sparse_global_order.ratio_coords", "0.15");
690690
ctx_ = Context(cfg);
691691

test/src/unit-result-tile.cc

+4-16
Original file line numberDiff line numberDiff line change
@@ -213,10 +213,7 @@ TEST_CASE_METHOD(
213213
0,
214214
std::nullopt,
215215
std::nullopt);
216-
ResultTile::TileData tile_data{
217-
{nullptr, ThreadPool::SharedTask()},
218-
{nullptr, ThreadPool::SharedTask()},
219-
{nullptr, ThreadPool::SharedTask()}};
216+
ResultTile::TileData tile_data{nullptr, nullptr, nullptr};
220217
rt.init_coord_tile(
221218
constants::format_version,
222219
array_schema,
@@ -233,10 +230,7 @@ TEST_CASE_METHOD(
233230
0,
234231
std::nullopt,
235232
std::nullopt);
236-
ResultTile::TileData tile_data{
237-
{nullptr, ThreadPool::SharedTask()},
238-
{nullptr, ThreadPool::SharedTask()},
239-
{nullptr, ThreadPool::SharedTask()}};
233+
ResultTile::TileData tile_data{nullptr, nullptr, nullptr};
240234
rt.init_coord_tile(
241235
constants::format_version,
242236
array_schema,
@@ -332,10 +326,7 @@ TEST_CASE_METHOD(
332326
0,
333327
std::nullopt,
334328
std::nullopt);
335-
ResultTile::TileData tile_data{
336-
{nullptr, ThreadPool::SharedTask()},
337-
{nullptr, ThreadPool::SharedTask()},
338-
{nullptr, ThreadPool::SharedTask()}};
329+
ResultTile::TileData tile_data{nullptr, nullptr, nullptr};
339330
rt.init_coord_tile(
340331
constants::format_version,
341332
array_schema,
@@ -352,10 +343,7 @@ TEST_CASE_METHOD(
352343
0,
353344
std::nullopt,
354345
std::nullopt);
355-
ResultTile::TileData tile_data{
356-
{nullptr, ThreadPool::SharedTask()},
357-
{nullptr, ThreadPool::SharedTask()},
358-
{nullptr, ThreadPool::SharedTask()}};
346+
ResultTile::TileData tile_data{nullptr, nullptr, nullptr};
359347
rt.init_coord_tile(
360348
constants::format_version,
361349
array_schema,

test/src/unit-sparse-global-order-reader.cc

+5-7
Original file line numberDiff line numberDiff line change
@@ -2202,10 +2202,9 @@ TEST_CASE_METHOD(
22022202
}
22032203

22042204
// FIXME: there is no per fragment budget anymore
2205-
// Two result tiles (2 * (2842 + 8)) = 5700 will be bigger than the per
2206-
// fragment budget (50000 * 0.11 / 2 fragments = 2750), so only one result
2207-
// tile will be loaded each time.
2208-
memory_.total_budget_ = "60000";
2205+
// Two result tile (2 * (~3000 + 8) will be bigger than the per fragment
2206+
// budget (1000).
2207+
memory_.total_budget_ = "35000";
22092208
memory_.ratio_coords_ = "0.11";
22102209
update_config();
22112210

@@ -2728,9 +2727,8 @@ TEST_CASE_METHOD(
27282727
}
27292728

27302729
// FIXME: there is no per fragment budget anymore
2731-
// Two result tiles (2 * (2842 + 8)) = 5700 will be bigger than the per
2732-
// fragment budget (40000 * 0.22 /2 frag = 4400), so only one will be loaded
2733-
// each time.
2730+
// Two result tile (2 * (~4000 + 8) will be bigger than the per fragment
2731+
// budget (1000).
27342732
memory_.total_budget_ = "40000";
27352733
memory_.ratio_coords_ = "0.22";
27362734
update_config();

test/src/unit-sparse-unordered-with-dups-reader.cc

+2-5
Original file line numberDiff line numberDiff line change
@@ -1064,12 +1064,9 @@ TEST_CASE_METHOD(
10641064

10651065
if (one_frag) {
10661066
CHECK(1 == loop_num->second);
1067+
} else {
1068+
CHECK(9 == loop_num->second);
10671069
}
1068-
/**
1069-
* We can't do a similar check for multiple fragments as it is architecture
1070-
* dependent how many tiles fit in the memory budget. And thus also
1071-
* architecture dependent as to how many internal loops we have.
1072-
*/
10731070

10741071
// Try to read multiple frags without partial tile offset reading. Should
10751072
// fail

tiledb/sm/filter/compression_filter.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ Status CompressionFilter::decompress_var_string_coords(
636636
auto output_view = span<std::byte>(
637637
reinterpret_cast<std::byte*>(output_buffer->data()), uncompressed_size);
638638
auto offsets_view = span<uint64_t>(
639-
offsets_tile->data_as_unsafe<offsets_t>(), uncompressed_offsets_size);
639+
offsets_tile->data_as<offsets_t>(), uncompressed_offsets_size);
640640

641641
if (compressor_ == Compressor::RLE) {
642642
uint8_t rle_len_bytesize, string_len_bytesize;

tiledb/sm/filter/filter_pipeline.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ Status FilterPipeline::run_reverse(
464464
// If the pipeline is empty, just copy input to output.
465465
if (filters_.empty()) {
466466
void* output_chunk_buffer =
467-
tile->data_as_unsafe<char>() + chunk_data.chunk_offsets_[i];
467+
tile->data_as<char>() + chunk_data.chunk_offsets_[i];
468468
RETURN_NOT_OK(input_data.copy_to(output_chunk_buffer));
469469
continue;
470470
}
@@ -487,7 +487,7 @@ Status FilterPipeline::run_reverse(
487487
bool last_filter = filter_idx == 0;
488488
if (last_filter) {
489489
void* output_chunk_buffer =
490-
tile->data_as_unsafe<char>() + chunk_data.chunk_offsets_[i];
490+
tile->data_as<char>() + chunk_data.chunk_offsets_[i];
491491
RETURN_NOT_OK(output_data.set_fixed_allocation(
492492
output_chunk_buffer, chunk.unfiltered_data_size_));
493493
reader_stats->add_counter(

tiledb/sm/filter/test/filter_test_support.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ Tile create_tile_for_unfiltering(
203203
tile->cell_size() * nelts,
204204
tile->filtered_buffer().data(),
205205
tile->filtered_buffer().size(),
206-
tracker,
207-
std::nullopt};
206+
tracker};
208207
}
209208

210209
void run_reverse(

tiledb/sm/filter/test/tile_data_generator.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ class TileDataGenerator {
9999
original_tile_size(),
100100
filtered_buffer.data(),
101101
filtered_buffer.size(),
102-
memory_tracker,
103-
std::nullopt);
102+
memory_tracker);
104103
}
105104

106105
/** Returns the size of the original unfiltered data. */

tiledb/sm/metadata/test/unit_metadata.cc

+3-6
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ TEST_CASE(
123123
tile1->size(),
124124
tile1->filtered_buffer().data(),
125125
tile1->filtered_buffer().size(),
126-
tracker,
127-
ThreadPool::SharedTask());
126+
tracker);
128127
memcpy(metadata_tiles[0]->data(), tile1->data(), tile1->size());
129128

130129
metadata_tiles[1] = tdb::make_shared<Tile>(
@@ -136,8 +135,7 @@ TEST_CASE(
136135
tile2->size(),
137136
tile2->filtered_buffer().data(),
138137
tile2->filtered_buffer().size(),
139-
tracker,
140-
ThreadPool::SharedTask());
138+
tracker);
141139
memcpy(metadata_tiles[1]->data(), tile2->data(), tile2->size());
142140

143141
metadata_tiles[2] = tdb::make_shared<Tile>(
@@ -149,8 +147,7 @@ TEST_CASE(
149147
tile3->size(),
150148
tile3->filtered_buffer().data(),
151149
tile3->filtered_buffer().size(),
152-
tracker,
153-
ThreadPool::SharedTask());
150+
tracker);
154151
memcpy(metadata_tiles[2]->data(), tile3->data(), tile3->size());
155152

156153
meta = Metadata::deserialize(metadata_tiles);

tiledb/sm/query/readers/dense_reader.cc

+27-32
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,6 @@ Status DenseReader::dense_read() {
453453
// processing.
454454
if (qc_coords_mode_) {
455455
t_start = t_end;
456-
if (compute_task.valid()) {
457-
throw_if_not_ok(compute_task.wait());
458-
}
459456
continue;
460457
}
461458

@@ -772,8 +769,8 @@ DenseReader::compute_result_space_tiles(
772769
const auto fragment_num = (unsigned)frag_tile_domains.size();
773770
const auto& tile_coords = subarray.tile_coords();
774771

775-
// Keep track of the required memory to load the result space tiles. Split
776-
// up filtered versus unfiltered. The memory budget is combined for all
772+
// Keep track of the required memory to load the result space tiles. Split up
773+
// filtered versus unfiltered. The memory budget is combined for all
777774
// query condition attributes.
778775
uint64_t required_memory_query_condition_unfiltered = 0;
779776
std::vector<uint64_t> required_memory_unfiltered(
@@ -789,28 +786,28 @@ DenseReader::compute_result_space_tiles(
789786
aggregate_only_field[n - condition_names.size()] = aggregate_only(name);
790787
}
791788

792-
// Here we estimate the size of the tile structures. First, we have to
793-
// account the size of the space tile structure. We could go deeper in the
794-
// class to account for other things but for now we keep it simpler. Second,
795-
// we try to account for the tile subarray (DenseTileSubarray). This class
796-
// will have a vector of ranges per dimensions, so 1 + dim_num *
797-
// sizeof(vector). Here we choose 32 for the size of the vector to
798-
// anticipate the conversion to a PMR vector. We also add dim_num * 2 *
799-
// sizeof(DimType) to account for at least one range per dimension (this
800-
// should be improved by accounting for the exact number of ranges). Finally
801-
// for the original range index member, we have to add 1 + dim_num *
802-
// sizeof(vector) as well and one uint64_t per dimension (this can also be
803-
// improved by accounting for the exact number of ranges).
789+
// Here we estimate the size of the tile structures. First, we have to account
790+
// the size of the space tile structure. We could go deeper in the class to
791+
// account for other things but for now we keep it simpler. Second, we try to
792+
// account for the tile subarray (DenseTileSubarray). This class will have a
793+
// vector of ranges per dimensions, so 1 + dim_num * sizeof(vector). Here we
794+
// choose 32 for the size of the vector to anticipate the conversion to a PMR
795+
// vector. We also add dim_num * 2 * sizeof(DimType) to account for at least
796+
// one range per dimension (this should be improved by accounting for the
797+
// exact number of ranges). Finally for the original range index member, we
798+
// have to add 1 + dim_num * sizeof(vector) as well and one uint64_t per
799+
// dimension (this can also be improved by accounting for the
800+
// exact number of ranges).
804801
uint64_t est_tile_structs_size =
805802
sizeof(ResultSpaceTile<DimType>) + (1 + dim_num) * 2 * 32 +
806803
dim_num * (2 * sizeof(DimType) + sizeof(uint64_t));
807804

808805
// Create the vector of result tiles to operate on. We stop once we reach
809-
// the end or the memory budget. We either reach the tile upper memory
810-
// limit, which is only for unfiltered data, or the limit of the available
811-
// budget, which is for filtered data, unfiltered data and the tile structs.
812-
// We try to process two tile batches at a time so the available memory is
813-
// half of what we have available.
806+
// the end or the memory budget. We either reach the tile upper memory limit,
807+
// which is only for unfiltered data, or the limit of the available budget,
808+
// which is for filtered data, unfiltered data and the tile structs. We try to
809+
// process two tile batches at a time so the available memory is half of what
810+
// we have available.
814811
uint64_t t_end = t_start;
815812
bool wait_compute_task_before_read = false;
816813
bool done = false;
@@ -898,8 +895,8 @@ DenseReader::compute_result_space_tiles(
898895
uint64_t tile_memory_filtered = 0;
899896
uint64_t r_idx = n - condition_names.size();
900897

901-
// We might not need to load this tile into memory at all for
902-
// aggregation only.
898+
// We might not need to load this tile into memory at all for aggregation
899+
// only.
903900
if (aggregate_only_field[r_idx] &&
904901
can_aggregate_tile_with_frag_md(
905902
names[n], result_space_tile, tiles_cell_num[t_end])) {
@@ -956,14 +953,13 @@ DenseReader::compute_result_space_tiles(
956953
required_memory_unfiltered[r_idx] +
957954
est_tile_structs_size;
958955

959-
// Disable the multiple iterations if the tiles don't fit in the
960-
// iteration budget.
956+
// Disable the multiple iterations if the tiles don't fit in the iteration
957+
// budget.
961958
if (total_memory > available_memory_iteration) {
962959
wait_compute_task_before_read = true;
963960
}
964961

965-
// If a single tile doesn't fit in the available memory, we can't
966-
// proceed.
962+
// If a single tile doesn't fit in the available memory, we can't proceed.
967963
if (total_memory > available_memory) {
968964
throw DenseReaderException(
969965
"Cannot process a single tile requiring " +
@@ -1007,8 +1003,7 @@ std::vector<ResultTile*> DenseReader::result_tiles_to_load(
10071003
const auto& tile_coords = subarray.tile_coords();
10081004
const bool agg_only = name.has_value() && aggregate_only(name.value());
10091005

1010-
// If the result is already loaded in query condition, return the empty
1011-
// list;
1006+
// If the result is already loaded in query condition, return the empty list;
10121007
std::vector<ResultTile*> ret;
10131008
if (name.has_value() && condition_names.count(name.value()) != 0) {
10141009
return ret;
@@ -1038,8 +1033,8 @@ std::vector<ResultTile*> DenseReader::result_tiles_to_load(
10381033

10391034
/**
10401035
* Apply the query condition. The computation will be pushed on the compute
1041-
* thread pool in `compute_task`. Callers should wait on this task before
1042-
* using the results of the query condition.
1036+
* thread pool in `compute_task`. Callers should wait on this task before using
1037+
* the results of the query condition.
10431038
*/
10441039
template <class DimType, class OffType>
10451040
Status DenseReader::apply_query_condition(

0 commit comments

Comments
 (0)