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.
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
generic lookup: pad queries to improve query cachability #10506
generic lookup: pad queries to improve query cachability #10506
Changes from all commits
2af0f28
83255a1
3d73937
cd95a4a
7382239
17badf0
707ff56
ef56079
01c81be
fe7e284
d0437ca
a117554
e1b4197
1eb9835
34625a5
ce0037d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Может сделать отсечку чтобы на слишком больших значениях уже таким не заниматься? Допустим приходит к нам 2^20+1 элемент всегда, а мы его будем расширять до 2^21. Выглядит как уже большой overhead на таких значениях. Либо же имеет смысл ограничивать шаг начиная с какой-то позиции. Например до 512 степенью двойки идти, а потом уже с шагом 512
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.
MaxKeysPerRequest ограничен 1k (лимит ydb на ответы). Если бы оно было бы больше, тут категорически НЕЛЬЗЯ было бы идти инкрементами, и обязательно пользоваться только степенями двойки: иначе тут получается O(n^2) вместо O(n), и на больших n это как раз существенно влияет
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.
Cама модель не правильная кмк. Асимптотическая нотация не подходит, так-как тут уже важны константы. Дальше на самом деле важно смотреть на K_i - число ключей в каждом запросе. K_i вполне себе ограничено. Нужно еще учитывать на сколько дороже компиляция станет и на сколько дорого добивать такими фековыми ключами запрос постоянно. Затем размер кеша компиляции не бесконечный и из него вымываются значения. Мое предположение что начиная с какого момента будут очень редкие выбросы и тогда не имеет смысла добавлять накладных расходов на добивание фейковыми значениями как 2x, а достаточно уже взять несколько бакетов по x + k * bucket_size
Сейчас понятно самая тривиальная идея используется, но думаю тут есть что улучшить. Нужно реальных данных насемплировать и по ним посмотреть. Это на уровнее идеи)
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.
Ещё есть альтернатива:
Вместо
(k1 = ? AND k2 = ?) OR (...)
использовать(k1,k2,...) IN ?
, где в? биндится к list of tuples. Никакого добивания, однократная компиляция, и минимальный размер запроса.Cons: требует не вполне тривиальной доработки в коннекторе, апдейта формата протобуфов (сейчас поддерживается только
(k1 IN ?)
(т.е. один ключ)), и будет работать только на ydb (впрочем, можно зафолбечить на тот же AND OR, только внутри коннектора).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.
О, это вообще отличная мысль на самом деле