Skip to content

Commit

Permalink
Fix arena growth being calculated with bytes instead of elements
Browse files Browse the repository at this point in the history
This caused excessively large arenas in some test scenarios,
with most of the allocated space unused
  • Loading branch information
embeddedt committed Apr 12, 2024
1 parent 7a9a7c1 commit 09c6306
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ public boolean upload(CommandList commandList, Stream<PendingUpload> stream) {
// If we weren't able to upload some buffers, they will have been left behind in the queue
if (!queue.isEmpty()) {
// Calculate the amount of memory needed for the remaining uploads
int remainingElements = queue.stream()
.mapToInt(upload -> upload.getDataBuffer().getLength())
.sum();
int remainingElements = (int)(queue.stream()
.mapToLong(upload -> upload.getDataBuffer().getLength())
.sum() / this.stride);

// Ask the arena to grow to accommodate the remaining uploads
// This will force a re-allocation and compaction, which will leave us a continuous free segment
Expand Down

0 comments on commit 09c6306

Please sign in to comment.