Add an option to treat "N/A" values as -infinity
Hi,
I noticed that lots of rows on I/O tab has "N/A" values and these N/As, according to sorting algorithm, are greater than any numeric value. It is hard to monitor the top of highest values - every time user should press page down several times and on average half of screen is wasted, and if number of processes with N/A changes the view jumps.
Sonuds like a bug to me. If the WBYTES field were stored in floating point, the compareRealNumbers function will correctly order "N/A" to before any non-NaN value.
But it's an integer comparison with LLONG_MAX or whatever that's reserved to mean "N/A".
Not sure if this helps, but I have one trick that may as well be implemented as a macro:
// 'io_write_bytes' uses ULLONG_MAX as "N/A"
SPACESHIP_NUMBER(p1->io_write_bytes + 1U, p2->io_write_bytes + 1U);
The +1 trick will only work with unsigned types without causing an undefined behavior (also the bit width of the field must be at least the width of unsigned int.
Doesn't compareRealNumbers have the same issue, but for the reversed order? For a floating point field such as IO_READ_RATE ordered from low to high, the N/A processes show up at the top. Unless that's by design.
@yinghao-w You can observe that "N/A" in IO_READ_RATE is ordered as lower than 0. That's by design.
@Explorer09 Thank you for your reply., I see it's by design. But these root processes can be reading the disk, so should they be grouped up with the processes that certainly aren't reading it at that time?
It wouldn't hurt to have the sorting at least consistent across int/float metrics.
FWIW: Having N/A values at the top is rarely what you want.
@BenBE
FWIW: Having N/A values at the top is rarely what you want.
Because the sort order can be ascending or descending, it would be inevitable for one of the two orders to show "N/A" values at the top. So I consider that part a non-issue.
But I agree the OP on the part that "N/A" values for integer entries should be sorted like -infinity.
Yes and no. There's the option of always putting N/A at the bottom, regardless of sorting order.
Yes and no. There's the option of always putting N/A at the bottom, regardless of sorting order.
I treat this suggestion as a separate feature request. Currently there's no such option in the Display Options Screen. And that option introduces another parameter in the sort comparison function. For a better code structure, I don't think I would work on that until the Vector_sort API discussion (#1785) is finished first.