github-actions[bot] commented on code in PR #4488:
URL: https://github.com/apache/iggy/pull/4488#discussion_r4247919210


##########
core/partitions/src/messages_writer.rs:
##########
@@ -196,6 +197,7 @@ async fn write_frozen_chunked<const ALIGN: usize>(
             );
             IggyError::CannotWriteToFile
         })?;
+        DISK_USAGE.charge(chunk_size as u64);

Review Comment:
   warning: `preallocate_file` charges the blocks `fallocate` already allocated 
for a reserved segment (`fs_utils.rs:89`). This line charges the same bytes 
again as writes fill that segment, so `disk_used_bytes` reports the volume as 
fuller by the bytes written since the last sample. Charge the reservation or 
the writes, not both. Also at 
`core/journal/src/partition_journal/segments.rs:433` and `:451`.



##########
core/journal/src/partition_journal/segments.rs:
##########
@@ -423,10 +425,12 @@ impl<S: DurableStorage> PartitionPrepareJournal<S> {
                 
buffers.push(prepares[index].slice(size_of::<PrepareHeader>()..));
                 bodies.next();
             }
+            let body_bytes = buffers.iter().map(Frozen::len).sum::<usize>() as 
u64;

Review Comment:
   simplification: The new `body_bytes` sum walks `buffers` again, though the 
push loop above already holds every slice length. Add each length to a counter 
while pushing, or reuse `end - first.position`, which holds the same total.



##########
core/integration/src/harness/disk.rs:
##########
@@ -114,6 +115,38 @@ pub fn walk(root: &Path, matches: &mut dyn FnMut(&Path) -> 
bool) -> Option<PathB
     None
 }
 
+/// Bytes the filesystem has allocated for `root` and everything under it, the
+/// way `du` counts them: from `st_blocks`, each inode once. File lengths would
+/// count a WAL hard link to a segment body twice and miss the preallocated
+/// tail of a segment.
+pub fn allocated_bytes(root: &Path) -> u64 {

Review Comment:
   simplification: `allocated_bytes()` has no caller outside its own two tests, 
because the disk usage test uses `volume_used_bytes()`. Delete the helper and 
its tests, or use them in a test that counts data-directory bytes.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to