-
Notifications
You must be signed in to change notification settings - Fork 155
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
[eleveldb][leo_backend_db] Impl iterater_move in batch #994
Comments
@mocchira I've just confirmed your idea. I agree to it. |
@yosukehara Thanks for taking time. I will go ahead from now. |
After some experiments, I've decided to change the new I/F as below. %% This may return 30 items in BatchItems at most or less than 30 if it hits EOF.
%% We can expect this function to decrease the CPU cost as it lowers the number of interactions between erlang runtime and NIF.
{ok, BatchItems} = eleveldb:first_n(DBRef, 30), Comparison to the previous I/F
However the iterating function we are using in leo_mq now is ONLY
That said, just covering the first_n use case would solve most of our CPU hog problem for now. |
@mocchira I've reviewed your idea, and I agree to deliver its function:
{ok, BatchItems} = eleveldb:first_n(DBRef, NumberOfItems) |
As it turned out that interactions (to be precise, sending a message from an OS thread to an erlang scheduler thread) between erlang runtime and NIF are NOT negligible (hogged CPU rather than Disk I/O) especially if the number of call times is relatively large (For more details and evidences, see #974).
leo-project/eleveldb@61c1f5b has solved #974 by making the number of interactions from the number of records to 1 so let's take a step forward with this method, we can make this hack being applied to other iterator functions by adding a new I/F to eleveldb to iterate over items in a certain batch size, for example,
With this hack, we might be able to solve #710.
I'm going to try on the next working day.
The text was updated successfully, but these errors were encountered: