Skip to content

slabtop: implement human - #808

Open
Bluemangoo wants to merge 1 commit into
uutils:mainfrom
Bluemangoo:feature/slabtop-human
Open

Bluemangoo wants to merge 1 commit into
uutils:mainfrom
Bluemangoo:feature/slabtop-human

Conversation

@Bluemangoo

Copy link
Copy Markdown
Collaborator

Add human readable option, exactly for CACHE SIZE in both header and table.

Notably, there is a slight format difference between ours and GNU. Anyway, it is unrelated to this PR.

tips: this PR has git conflict with #805


from GNU:

sudo slabtop -o     
 Active / Total Objects (% used)    : 1850277 / 1910721 (96.8%)
 Active / Total Slabs (% used)      : 46565 / 46565 (100.0%)
 Active / Total Caches (% used)     : 146 / 206 (70.9%)
 Active / Total Size (% used)       : 514322 / 527683 (97.5%)
 Minimum / Average / Maximum Object : 0.01K / 0.28K / 8.81K

    OBJS   ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME                 
  230664   229897  99%    0.19K   5492       42      43936 dentry                 
  169142   168409  99%    0.09K   3677       46      14708 lsm_inode_cache        
  149968   149811  99%    0.57K   5356       28      85696 radix_tree_node        
  129120   129062  99%    1.00K   4035       32     129120 btrfs_inode            
  109548   104820  95%    0.04K   1074      102       4296 vma_lock               
  108100   104661  96%    0.17K   2350       46      18800 vm_area_struct         
   98700    98496  99%    0.31K   3948       25      31584 xfrm_dst               
   93639    92541  98%    0.10K   2401       39       9604 btrfs_free_space       
   84830    63785  75%    0.23K   2495       34      19960 btrfs_extent_buffer    
   64704    60906  94%    0.06K   1011       64       4044 anon_vma_chain         
   64650    64650 100%    0.13K   2155       30       8620 kernfs_node_cache    
***
      32       32 100%    0.25K      1       32          8 bio-248                
      32       32 100%    8.00K      8        4        256 memdup_user-8k         
      32       32 100%    0.12K      1       32          4 memdup_user-128        
      30       30 100%    1.06K      1       30         32 dmaengine-unmap-128    
      30       30 100%    0.27K      1       30          8 numa_policy            
      25       25 100%    0.31K      1       25          8 bio-312                
      25       25 100%    0.31K      1       25          8 bio-256                
      21       21 100%    1.50K      1       21         32 x86_lbr                
      16       16 100%    2.00K      1       16         32 biovec-128             
      15       15 100%    2.06K      1       15         32 dmaengine-unmap-256    
       0        0   0%    0.22K      0       36          0 nf_conntrack_expect    
       0        0   0%    0.04K      0      102          0 fat_cache              
       0        0   0%    8.81K      0        3          0 kvm_vcpu               
       0        0   0%    0.18K      0       44          0 kvm_mmu_page_header    
       0        0   0%    2.61K      0       12          0 x86_emulator                   
sudo slabtop -o --human
 Active / Total Objects (% used)    : 1877116 / 1935713 (97.0%)
 Active / Total Slabs (% used)      : 47202 / 47202 (100.0%)
 Active / Total Caches (% used)     : 146 / 206 (70.9%)
 Active / Total Size (% used)       : 509Mi / 522Mi (97.5%)
 Minimum / Average / Maximum Object : 0.01K / 0.28K / 8.81K

    OBJS   ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME                 
  235410   234891  99%    0.19K   5605       42       43Mi dentry                 
  171166   169825  99%    0.09K   3721       46       14Mi lsm_inode_cache        
  152852   152337  99%    0.57K   5459       28       85Mi radix_tree_node        
  130560   130560 100%    1.00K   4080       32      127Mi btrfs_inode            
  110772   106421  96%    0.04K   1086      102      4.2Mi vma_lock               
  110170   106029  96%    0.17K   2395       46       18Mi vm_area_struct         
  100625   100191  99%    0.31K   4025       25       31Mi xfrm_dst               
   93015    91602  98%    0.10K   2385       39      9.3Mi btrfs_free_space       
   84830    64499  76%    0.23K   2495       34       19Mi btrfs_extent_buffer    
   65920    61734  93%    0.06K   1030       64      4.0Mi anon_vma_chain         
   64710    64478  99%    0.13K   2157       30      8.4Mi kernfs_node_cache
***
      32       32 100%    0.25K      1       32      8.0Ki bio-248                
      32       32 100%    8.00K      8        4      256Ki memdup_user-8k         
      32       32 100%    0.12K      1       32      4.0Ki memdup_user-128        
      30       30 100%    1.06K      1       30       32Ki dmaengine-unmap-128    
      30       30 100%    0.27K      1       30      8.0Ki numa_policy            
      25       25 100%    0.31K      1       25      8.0Ki bio-312                
      25       25 100%    0.31K      1       25      8.0Ki bio-256                
      21       21 100%    1.50K      1       21       32Ki x86_lbr                
      16       16 100%    2.00K      1       16       32Ki biovec-128             
      15       15 100%    2.06K      1       15       32Ki dmaengine-unmap-256    
       0        0   0%    0.22K      0       36         0B nf_conntrack_expect    
       0        0   0%    0.04K      0      102         0B fat_cache              
       0        0   0%    8.81K      0        3         0B kvm_vcpu               
       0        0   0%    0.18K      0       44         0B kvm_mmu_page_header    
       0        0   0%    2.61K      0       12         0B x86_emulator   

from this PR:

cargo build --package uu_slabtop -q&&sudo ./target/debug/slabtop -o
 Active / Total Objects (% used)    : 1871110 / 1935103 (96.7%)
 Active / Total Slabs (% used)      : 47191 / 47191 (100.0%)
 Active / Total Caches (% used)     : 532257104 / 547074000 (97.3%)
 Active / Total Size (% used)       : 519782 / 534251 (97.3%)
 Minimum / Average / Maximum Object : 0.01K / 0.93K / 8.81K

  OBJS ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME
234948 233942 100%    0.19K   5594       42      44052 dentry
171120 169759  99%    0.09K   3720       46      14705 lsm_inode_cache
152656 151948 100%    0.57K   5452       28      87061 radix_tree_node
130528 130528 100%    1.00K   4079       32     130528 btrfs_inode
110772 106141  96%    0.04K   1086      102       4327 vma_lock
110170 105786  96%    0.17K   2395       46      18935 vm_area_struct
100475  99986 100%    0.31K   4019       25      31398 xfrm_dst
 93015  91243  98%    0.10K   2385       39       9446 btrfs_free_space
 84830  64535  76%    0.23K   2495       34      19882 btrfs_extent_buffer
 65920  61927  94%    0.06K   1030       64       4120 anon_vma_chain
 64710  64478 100%    0.13K   2157       30       8594 kernfs_node_cache
***
    32     32 100%    0.25K      1       32          8 bio-248
    32     32 100%    8.00K      8        4        256 memdup_user-8k
    32     32 100%    0.12K      1       32          4 memdup_user-128
    30     30 100%    1.06K      1       30         31 dmaengine-unmap-128
    30     30 100%    0.27K      1       30          7 numa_policy
    25     25 100%    0.31K      1       25          7 bio-312
    25     25 100%    0.31K      1       25          7 bio-256
    21     21 100%    1.50K      1       21         31 x86_lbr
    16     16 100%    2.00K      1       16         32 biovec-128
    15     15 100%    2.06K      1       15         30 dmaengine-unmap-256
     0      0   0%    0.22K      0       36          0 nf_conntrack_expect
     0      0   0%    0.04K      0      102          0 fat_cache
     0      0   0%    8.81K      0        3          0 kvm_vcpu
     0      0   0%    0.18K      0       44          0 kvm_mmu_page_header
     0      0   0%    2.61K      0       12          0 x86_emulator
cargo build --package uu_slabtop -q&&sudo ./target/debug/slabtop -o --human
 Active / Total Objects (% used)    : 1876620 / 1935668 (96.9%)
 Active / Total Slabs (% used)      : 47204 / 47204 (100.0%)
 Active / Total Caches (% used)     : 533960312 / 547844760 (97.5%)
 Active / Total Size (% used)       : 509Mi / 522Mi (97.5%)
 Minimum / Average / Maximum Object : 0.01K / 0.93K / 8.81K

  OBJS ACTIVE  USE OBJ SIZE  SLABS OBJ/SLAB CACHE SIZE NAME
235410 234934 100%    0.19K   5605       42       43Mi dentry
171166 169940  99%    0.09K   3721       46       14Mi lsm_inode_cache
152852 152296 100%    0.57K   5459       28       85Mi radix_tree_node
130560 130560 100%    1.00K   4080       32      127Mi btrfs_inode
110772 106125  96%    0.04K   1086      102      4.2Mi vma_lock
110170 106119  96%    0.17K   2395       46       18Mi vm_area_struct
100600 100147 100%    0.31K   4024       25       30Mi xfrm_dst
 93015  91561  98%    0.10K   2385       39      9.2Mi btrfs_free_space
 84830  64394  76%    0.23K   2495       34       19Mi btrfs_extent_buffer
 65920  62155  94%    0.06K   1030       64      4.0Mi anon_vma_chain
 64710  64478 100%    0.13K   2157       30      8.4Mi kernfs_node_cache
***
    25     25 100%    0.31K      1       25      7.0Ki bio-256
    21     21 100%    1.50K      1       21       31Ki x86_lbr
    16     16 100%    2.00K      1       16       32Ki biovec-128
    15     15 100%    2.06K      1       15       30Ki dmaengine-unmap-256
     0      0   0%    0.22K      0       36         0B nf_conntrack_expect
     0      0   0%    0.04K      0      102         0B fat_cache
     0      0   0%    8.81K      0        3         0B kvm_vcpu
     0      0   0%    0.18K      0       44         0B kvm_mmu_page_header
     0      0   0%    2.61K      0       12         0B x86_emulator

Copilot AI balanced review requested due to automatic review settings October 3, 2026 08:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 12.85714% with 61 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.39%. Comparing base (67832aa) to head (b7fa2c6).
⚠️ Report is 16 commits behind head on main.

Files with missing lines Patch % Lines
src/uu/slabtop/src/slabtop.rs 0.00% 58 Missing ⚠️
tests/by-util/test_slabtop.rs 75.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #808      +/-   ##
==========================================
+ Coverage   19.20%   19.39%   +0.19%     
==========================================
  Files          68       68              
  Lines       10156    10271     +115     
  Branches      546      560      +14     
==========================================
+ Hits         1950     1992      +42     
- Misses       8206     8279      +73     
Flag Coverage Δ
macos_latest 6.72% <0.00%> (-0.03%) ⬇️
ubuntu_latest 19.75% <12.85%> (+0.19%) ⬆️
windows_latest 0.02% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/uu/slabtop/Cargo.toml Outdated
uucore = { workspace = true }
clap = { workspace = true }

uu_free = { path = "../free" }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i am not a fan of a util depending on another util crate.
could you please move humanized to a shared place instead (uucore or a small common module)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

procps' humanized is different from coreutils' (see #431 )

our common module is on the way #802 , or should I create a new crate for it?

anyway humanized is dependented by 3 utils. I agree that it is necessary to move it in a shared place.

@Krysztal112233 #805 did the same things.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid finding ourselves in the same situation as uu_pgrep, I agree with moving it to a separate crate.

However, I believe a new pull request should be opened for this purpose.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I raised the same matter in #805.

For this pull request, I would prefer to make a copy of humanize and mark it with a TODO

https://github.com/uutils/procps/pull/805/changes#diff-c688968ac8ebaba2efb54384b54dd19e8ca7ed3e470510ed52963adf5eccc981R456-R459

Comment thread src/uu/slabtop/src/slabtop.rs Outdated
Comment thread src/uu/slabtop/src/slabtop.rs Outdated
Comment thread src/uu/slabtop/src/slabtop.rs
@Bluemangoo
Bluemangoo force-pushed the feature/slabtop-human branch from 3e8cef2 to b5331c4 Compare October 4, 2026 07:56
Copilot AI balanced review requested due to automatic review settings October 4, 2026 07:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Bluemangoo
Bluemangoo force-pushed the feature/slabtop-human branch from b5331c4 to 72e7c6c Compare October 4, 2026 07:57
Copilot AI balanced review requested due to automatic review settings October 4, 2026 07:57

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Bluemangoo

Copy link
Copy Markdown
Collaborator Author

made a copy of humanize and marked with TODO. fixed the rest issues.

@Bluemangoo
Bluemangoo requested a review from sylvestre October 4, 2026 08:03
Comment thread src/uu/slabtop/src/slabtop.rs Outdated
Comment thread tests/by-util/test_slabtop.rs Outdated
Copilot AI balanced review requested due to automatic review settings October 4, 2026 08:42
@Bluemangoo
Bluemangoo force-pushed the feature/slabtop-human branch from 72e7c6c to d18de49 Compare October 4, 2026 08:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Bluemangoo

Copy link
Copy Markdown
Collaborator Author

removed the dependency on bytesize and added a small tip to avoid confusion when moving it to a shared crate.

I have no idea about the unit test for the formatting. should I add a unit test for the removing 'K'? or duplicate the test for humanized from uu_free? or just add a small test for the helper format_size?

@Bluemangoo
Bluemangoo requested a review from sylvestre October 4, 2026 08:58
Copilot AI balanced review requested due to automatic review settings October 19, 2026 14:24

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@Bluemangoo
Bluemangoo force-pushed the feature/slabtop-human branch from 9499407 to b7fa2c6 Compare October 20, 2026 06:52
Copilot AI balanced review requested due to automatic review settings October 20, 2026 06:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants