-
Notifications
You must be signed in to change notification settings - Fork 9
Restructure Matrix read operations #314
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
Open
NikolaosPapailiou
wants to merge
3
commits into
main
Choose a base branch
from
npapa/sc-43913/batched-matix-read-operation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,28 @@ | |
#include <string> | ||
#include <tiledb/tiledb> | ||
|
||
// Default batch size for all TileDB read operations. | ||
// This is expressed in number of array cells read per request. | ||
constexpr size_t DEFAULT_READ_BATCH_SIZE_CELLS = 100000000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest using |
||
constexpr char READ_BATCH_SIZE_CELLS_CONFIG_KEY[] = | ||
"vectorsearch.read_batch_size_cells"; | ||
static size_t get_read_batch_size_cells(const tiledb::Context& ctx) { | ||
auto config = ctx.config(); | ||
if (config.contains(READ_BATCH_SIZE_CELLS_CONFIG_KEY)) { | ||
auto tmp_str = config.get(READ_BATCH_SIZE_CELLS_CONFIG_KEY); | ||
try { | ||
size_t read_batch_size_cells = std::stoull(tmp_str); | ||
return read_batch_size_cells; | ||
} catch (const std::invalid_argument& e) { | ||
throw std::invalid_argument( | ||
"Failed to convert 'vectorsearch.read_batch_size_cells' to size_t " | ||
"('" + | ||
tmp_str + "')"); | ||
} | ||
} | ||
return DEFAULT_READ_BATCH_SIZE_CELLS; | ||
} | ||
|
||
template <class... T> | ||
constexpr bool always_false = false; | ||
|
||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this result in incomplete queries whenever
read_batch_size_cells
is less thantotal_size
? I don't think we should batch read unless we actually need to. That is, we should always try to readtotal_size
and then iterate if we don't gettotal_size
.Having incomplete queries here is a very edge case. Reading in batches may or may not solve that issue, but it adds latency to the common case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of
read_batch_size_cells
is to setup a cap on the individual request size to TileDB. The cap is configurable, so we could set it to a large value in order to perform all requests in one go.To explain why I expect this to reduce our memory footprint without large latency overhead, lets use an example:
tiledb://
arrayThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One rule in software is "don't pay for what you don't need." It is true that there is only a 5% penalty with this particular set of assumptions. However, I expect the server is going to deal with its memory footprint in its own way, which is why we might get incomplete reads. I would say just request what is needed and let the server say how much memory it wants to devote to that or not.
Do other apps try to be parsimonious this way?
I guess, on the other hand, since this is configurable, we can always just make it really large.