-
Notifications
You must be signed in to change notification settings - Fork 978
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
Array lists with set capacities in SimpleBatcher #2445
Labels
type: feature
A new feature
Milestone
Comments
Preallocation makes some sense to avoid collection resizing. Indeed, the preallocation calculation is wrong, it should rather be |
mp911de
added a commit
that referenced
this issue
Jul 17, 2023
That's fixed now. |
mp911de
added a commit
that referenced
this issue
Jul 17, 2023
mp911de
added a commit
that referenced
this issue
Jul 17, 2023
LGTM. WTG extracting a method there. Future improvements:
|
Feel free to submit a pull request. Happy to merge improvements if they make sense. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature Request
This is not exactly a feature request, but a potential enhancement request. While working on #2444, I noticed this array list with a set capacity:
This logic actually appears three times inside
SimpleBatcher
. My questions are:max(..., 10)
?I'm asking this because in the code I'm working on, I thought about setting
@BatchSize()
to a huge value likeInteger.MAX_VALUE
in order to operate solely on manual flushes viaflush()
calls. The problem is that those lists are being preallocated according to the value in the annotation, so one quickly runs into an OOM if@BatchSize()
is too big (that's how I found that code).My enhancement proposal is to stop setting the capacity on those lists. In case my suggestion is welcome, I would also propose we further improve that code by not even having to allocate new lists inside
prepareForceFlush()
andprepareDefaultFlush()
, but instead relying solely on the one created insideflush()
(and thus avoid an unnecessary extra copy as well).Thoughts? I'd be glad to create a PR for it, but I wanted to check here first if you think it makes sense.
Thanks!
The text was updated successfully, but these errors were encountered: