Skip to content

Conversation

@GermanAizek
Copy link
Contributor

@GermanAizek GermanAizek commented Apr 21, 2025

@tbzatek,
This PR will decrease costs copying, moving, and creating object-structures only for common 64bit processors due to the 8-byte data alignment.

Smaller size structure or class, higher chance putting into CPU cache. Most processors are already 64 bit, so the change won't make it any worse.

Info about technique:

https://hpc.rz.rptu.de/Tutorials/AVX/alignment.shtml

https://wr.informatik.uni-hamburg.de/_media/teaching/wintersemester_2013_2014/epc-14-haase-svenhendrik-alignmentinc-presentation.pdf

https://en.wikipedia.org/wiki/Data_structure_alignment

https://stackoverflow.com/a/20882083

https://zijishi.xyz/post/optimization-technique/learning-to-use-data-alignment/

Affected structs:

  • _UDisksLinuxDriveAta
  • SynthUeventData
  • _UDisksBaseJobPrivate

Affected structs:

- _UDisksLinuxDriveAta
- SynthUeventData
-_UDisksBaseJobPrivate
@tbzatek
Copy link
Member

tbzatek commented Apr 23, 2025

Jenkins, ok to test.

@tbzatek
Copy link
Member

tbzatek commented May 14, 2025

Well I understand your point of optimizing cachelines, though its real impact is questionable in a project that spends much more CPU cycles with GObject machinery, marshalling/demarshalling data types and translating structures for D-Bus objects. Especially in the context of data structures that are not so often used.

FYI, beware of certain GObject requirements for subclassing (that are not an issue in this PR), such as embedding whole structs of parent classes (as a first struct member).

@GermanAizek
Copy link
Contributor Author

Updated to master branch.

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.

2 participants