Skip to content

Don't clone positions when checking is batch completed - #303

Open
saitiart wants to merge 1 commit into
lichess-org:mainfrom
saitiart:queue-batch-optimization
Open

saitiart wants to merge 1 commit into
lichess-org:mainfrom
saitiart:queue-batch-optimization

Conversation

@saitiart

Copy link
Copy Markdown

try_into_completed() cloned self.positions on every call so it could hand self back in case of Err. Since maybe_finished() runs after each chunk, this is rather inneficient since it deep clones all responses and then just discards them.

I replaced it with a check (is_complete) and after a consuming conversion (into_completed) only if the check passes.
maybe_finished now uses get_mut and removes the entry once instead of remove + re-insert on every call.
On the performance side, I havent had a way to measure the speedup and its presumably not significant, but it reduces redundant memory operations.

This branch has not been deployed

No deployments
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.

1 participant