Skip to content

Review libflow's interface#268

Merged
AltraMayor merged 16 commits intomasterfrom
clean-libflow
Apr 16, 2026
Merged

Review libflow's interface#268
AltraMayor merged 16 commits intomasterfrom
clean-libflow

Conversation

@AltraMayor
Copy link
Copy Markdown
Owner

Since spinning off f3write in 2020, libflow has become a key aspect of how F3 works and is currently employed in f3write, f3read, f3brew, and f3probe. This pull request streamlines the interface of libflow by

  1. Unifying size units with blocks. Each file system and block device has a block unit. Adopting the block unit of the underlying storage minimizes size conversions between units: bytes, sectors, and blocks; and
  2. Operating with block order instead of block size. A block size is a power of 2, so operating with its exponent (i.e., $\log_2(\text{block size})$) simplifies arithmetic by replacing multiplications, divisions, and modulos with bit operations: left shift (<<), right shift (>>), and AND (&).

In addition, this interface review brings the following minor improvements:

  1. Improved type safety by converting non-negative quantities (e.g., block counts, orders, and sizes) from signed to unsigned integers.
  2. Renamed fields and functions to clarify that they operate on blocks rather than bytes (e.g., total_sizetotal_blocks, stepstep_blocks, and get_rem_chunk_size()get_rem_chunk_blocks()).
  3. Dropped outdated func_flush_chunk parameter from init_flow() and the redundant total_processed field from struct flow.
  4. Improved accuracy of the reported initial speed in start_measurement().
  5. Made dbuf_get_buf() alignment-aware, so several callers dropped their ad hoc solutions for memory alignment.

@AltraMayor AltraMayor force-pushed the clean-libflow branch 7 times, most recently from 9c3c981 to 619bfee Compare April 16, 2026 13:48
Mixing the types uint64_t and `unsigned long long` does not compile
on platforms that map uint64_t to `unsigned long long` instead of
`unsigned long`.

In addition, this commit uses the largest type between (a) and (b)
instead of only the type of (a).
f3write was the only user of parameter func_flush_chunk of
init_flow().
Making dbuf_get_buf() alignment aware simplifies the code since
callers no longer need to deal with alignment.
Field total_processed can be derived from fields measured_blocks,
processed_blocks, and block_size.
There's no need to mix signed and unsigned fields in struct flow.
Most of the code in the commit is to refactor the code for
the change of unit from bytes to blocks.
This commit also changes the parameter processed of measure() to
processed_blocks.
@AltraMayor AltraMayor force-pushed the clean-libflow branch 3 times, most recently from 8a17b56 to 6f0240f Compare April 16, 2026 20:56
@AltraMayor AltraMayor force-pushed the clean-libflow branch 2 times, most recently from 5631495 to f465796 Compare April 16, 2026 21:39
@AltraMayor AltraMayor marked this pull request as ready for review April 16, 2026 22:15
@AltraMayor AltraMayor merged commit 6769959 into master Apr 16, 2026
26 checks passed
@AltraMayor AltraMayor deleted the clean-libflow branch April 16, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant