[LU-2825] shrink cl_page structure size Created: 18/Feb/13  Updated: 08/Feb/18  Resolved: 08/Feb/18

Status: Closed
Project: Lustre
Component/s: None
Affects Version/s: Lustre 2.4.0
Fix Version/s: None

Type: Improvement Priority: Major
Reporter: Andreas Dilger Assignee: Jinshan Xiong (Inactive)
Resolution: Won't Fix Votes: 0
Labels: patch

Rank (Obsolete): 6841

 Description   

Looking at struct cl_page there seems to be a lot of wasted memory, and since there may be millions of these structures in memory for every client, this wasted space can be considerable.

  • 32-bit cp_ref is followed by 64-bit cp_obj, wastes 4 bytes
  • 32-bit cp_state is followed by 64-bit cp_batch, wastes 4 bytes
  • cp_state only has 5 states, could fit into a 3-bit field
  • cp_type only has 1 bit, could fit into a 1-bit field, and is immutable after creation so no worries about racy updates/locking
  • 32-bit cp_flags is followed by 64-bit cp_sync_io, wastes 4 bytes
  • cp_flags only has 1 bit, could fit into a 1-bit field (not totally sure about locking)
  • 64-bit cp_task is only set in 2 places, and never used
  • 64-bit cp_queue_ref and cp_obj_ref are only used under USE_LU_REF and can also be made conditional

The structure cl_req has similar space wastage, though it isn't used as often as cl_page:

  • 32-bit crq_type is followed by 64-bit crq_pages, wastes 4 bytes
  • crq_type only uses two flags, could be a bitfield
  • 32-bit crq_npages is followed by 64-bi crq_o, wastes 4 bytes
  • 32-bit crq_nrobjs is followed by 64-bit crq_layers, wastes 4 bytes

Using the "pahole" program (part of the "dwarves" package) can report on binary structures for space wastage and alignment problems.



 Comments   
Comment by Swapnil Pimpale (Inactive) [ 02/Aug/13 ]

Hi Andreas,

I have opened a review request for this here -> http://review.whamcloud.com/#/c/7210/
I have made the following changes:

cl_page:
1) changed the position of cp_ref, cp_state, cp_flags and cp_type to better suit the alignment.
2) Converted cp_flags and cp_type members to bitfields of sizes 1 and 2 bits respectively.
3) Could not change cp_state to a bitfield since we access its address at one place.
This leads to a saving of 16 bytes.

cl_req:
1) changed the position of crq_nrpages for better alignment.
2) converted crq_type to a bitfield of 2 bits.
This leads to a saving of 8 bytes.

Comment by Jinshan Xiong (Inactive) [ 08/Feb/18 ]

close old tickets

Generated at Sat Feb 10 01:28:31 UTC 2024 using Jira 9.4.14#940014-sha1:734e6822bbf0d45eff9af51f82432957f73aa32c.