Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use new memory tracker for tile offsets #4929

Merged
merged 10 commits into from
May 20, 2024

Conversation

DimitrisStaratzis
Copy link
Member

@DimitrisStaratzis DimitrisStaratzis commented May 1, 2024

This PR is responsible for two things:

  1. Fix the memory usage estimation for the tile offsets to match the memory tracker result
  2. Switch to use the new memory tracker for offsets only. (All readers related)

[sc-46275]


TYPE: NO_HISTORY
DESC: Use new memory tracker for tile offsets.

@@ -253,8 +253,7 @@ void SparseUnorderedWithDupsReader<BitmapType>::load_tile_offsets_data() {
tile_offsets_min_frag_idx_ == std::numeric_limits<unsigned>::max() &&
tile_offsets_max_frag_idx_ == 0;
uint64_t available_memory =
array_memory_tracker_->get_memory_available() -
array_memory_tracker_->get_memory_usage(MemoryType::TILE_OFFSETS);
array_memory_tracker_->get_memory_available();
Copy link
Contributor

Choose a reason for hiding this comment

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

get_memory_available should be changed so that tile offsets from the new counters are subtracted.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have done that.

@DimitrisStaratzis DimitrisStaratzis force-pushed the dstara/use_new_memory_tracker_for_offsets branch 2 times, most recently from 72de436 to 2441e3d Compare May 13, 2024 12:46
@DimitrisStaratzis DimitrisStaratzis changed the title Dstara/use new memory tracker for offsets use new memory tracker for tile offsets May 13, 2024
@DimitrisStaratzis DimitrisStaratzis changed the title use new memory tracker for tile offsets Use new memory tracker for tile offsets May 13, 2024
@DimitrisStaratzis DimitrisStaratzis force-pushed the dstara/use_new_memory_tracker_for_offsets branch 3 times, most recently from 4afb631 to 809c0bf Compare May 13, 2024 14:39
@DimitrisStaratzis DimitrisStaratzis marked this pull request as ready for review May 13, 2024 15:31
@DimitrisStaratzis DimitrisStaratzis marked this pull request as draft May 15, 2024 17:15
@DimitrisStaratzis DimitrisStaratzis force-pushed the dstara/use_new_memory_tracker_for_offsets branch 2 times, most recently from 7ca6d12 to 14e35a7 Compare May 16, 2024 11:18
@DimitrisStaratzis DimitrisStaratzis force-pushed the dstara/use_new_memory_tracker_for_offsets branch from a18b159 to 44d601e Compare May 16, 2024 13:38
@DimitrisStaratzis DimitrisStaratzis marked this pull request as ready for review May 16, 2024 13:38
Copy link
Contributor

@KiterLuc KiterLuc left a comment

Choose a reason for hiding this comment

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

Just add a few more comments please.

@@ -312,7 +312,10 @@ class MemoryTracker {
*/
uint64_t get_memory_available() {
std::lock_guard<std::mutex> lg(mutex_);
return memory_budget_ - memory_usage_;
if (memory_usage_ + counters_[MemoryType::TILE_OFFSETS] > memory_budget_) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

// Finally set the size of the loaded data.
ret[frag_idx] = num * tile_num * sizeof(uint64_t);
ret[frag_idx] =
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to explain the 4 and 32.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

unsigned num_vectors = schema->attribute_num() + 1 +
fragment->has_timestamps() +
fragment->has_delete_meta() * 2;
num_vectors += (fragment->version() >= 5) ? schema->dim_num() : 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a comment on this line as to what it does... For fragments up to version 4, we use zipped coordinates.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

// Other than the offsets themselves, there is also memory used for the
// initialization of the vectors that hold them. This initialization
// takes place in fragment_metadata.cc::load_footer()
unsigned num_vectors = schema->attribute_num() + 1 +
Copy link
Contributor

Choose a reason for hiding this comment

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

Document the +1. I think it's the old zipped coords?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the only thing I don't understand. What this +1 stands for. It is documented nowhere

// Other than the offsets themselves, there is also memory used for the
// initialization of the vectors that hold them. This initialization
// takes place in fragment_metadata.cc::load_footer()
unsigned num_vectors = schema->attribute_num() + 1 +
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
unsigned num_vectors = schema->attribute_num() + 1 +
unsigned num_fields = schema->attribute_num() + 1 +

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@KiterLuc KiterLuc merged commit 0942e4e into dev May 20, 2024
60 checks passed
@KiterLuc KiterLuc deleted the dstara/use_new_memory_tracker_for_offsets branch May 20, 2024 14:09
@DimitrisStaratzis DimitrisStaratzis restored the dstara/use_new_memory_tracker_for_offsets branch May 21, 2024 16:00
KiterLuc pushed a commit that referenced this pull request May 27, 2024
Fixes the nightly tests in windows after #4929. The memory budgets tests
were failing because structures take more memory in ASAN debug.
Adjusting the budgeting values so they pass in all build flavors.

Successful run here:
https://github.com/TileDB-Inc/TileDB/actions/runs/9209028209.

---
TYPE: NO_HISTORY
DESC: Update budget tests to fix windows nightly builds.
@DimitrisStaratzis DimitrisStaratzis deleted the dstara/use_new_memory_tracker_for_offsets branch May 29, 2024 11:33
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.

None yet

2 participants