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

Better spliterator #69

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Better spliterator #69

wants to merge 1 commit into from

Conversation

lavrukov
Copy link
Contributor

@lavrukov lavrukov commented May 15, 2024

The current implementation of the new spliterator was designed with minimal memory consumption in mind, as the ResultSet could be quite large. In YDB version 24.1, settings for response size for readTable have been introduced, so the current spliterator can be improved:

Idea:

  • We read the ResultSet from the database and feed it into a Stream. While the Stream processes the ResultSet, we simultaneously read a new ResultSet so that by the time the first one is processed, the second one is already prepared.
  • The Stream is almost lock-free. Locks taken only to fetch the ResultSet from the queue.
  • The YDB-thread reads the ResultSet and places it in the queue. AFTER appending, if the queue is full, the YDB-thread sleeps until something takes the ResultSet from the queue. This ensures that at any given moment, no more than N + 1 ResultSets are in memory, where N is the size of the queue.
  • If the element processing operation from the Stream is heavy, the process can be parallelized. YdbSpliteratorQueue supports fetching the ResultSet from multiple threads.

@lavrukov lavrukov force-pushed the better-spliterator branch 3 times, most recently from fbc1734 to 9e2201e Compare May 15, 2024 20:25
@nvamelichev nvamelichev added the feature New feature or request label May 17, 2024
@nvamelichev nvamelichev linked an issue May 17, 2024 that may be closed by this pull request
@lavrukov lavrukov force-pushed the better-spliterator branch 6 times, most recently from 030388c to 5b7eea7 Compare July 2, 2024 18:23
@lavrukov lavrukov changed the title [WIP] Better spliterator Better spliterator Jul 2, 2024
@lavrukov lavrukov force-pushed the better-spliterator branch 5 times, most recently from d4ffa8a to 96cbaa6 Compare July 2, 2024 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Performance test of YdbSpliterator
3 participants