Opened 7 years ago

Closed 4 years ago

#2030 closed task (duplicate)

[offline] Reduce memory footprint for I3Position and I3Direction

Reported by: David Schultz Owned by: Martina Karl
Priority: major Milestone: Autumnal Equinox 2020
Component: combo core Keywords:
Cc: Christopher Weaver

Description

One thing we should do at some point is to check low-level code optimizations:

  • struct packing
  • cpu cache usage vs memory layout
    • cache lines
    • data structure layout
    • loop ordering
  • profile-guided optimization?
    • expensive, but might be worth it for production

Probably should also run profiling tools over the whole code base and find hot spots to look into more deeply.

Change History (17)

comment:1 Changed 7 years ago by David Schultz

I investigated struct packing today. Here are some findings:

  • Consider making OMKey.stringNumber_ or OMKey.omNumber_ a short.
  • I3Position and I3Direction have variables for cartesian and spherical. Eliminate one of them, and save 24 bytes per object (greatly shrinking I3Particle).
    • Above elimination would get rid of isCalculated_, saving 8 bytes because of bool + padding.
  • Use c++11 enum in I3Particle to define number of bytes for each (defaults to int, but we could use char for many). Careful of the serialization here.
    • Same to I3DOMStatus, and likely other classes.
  • I3Orientation has lots of duplicate orientations cached.
  • I3EventHeader has 4 bytes of padding. fixing enum type and changing subRunID_ to short would save 8 bytes.
  • Stop using dataclasses/external/tree.hh (lots of padding issues that I don't want to fix).
  • I3FlasherInfo seems to waste space, using larger variables than necessary (which causes padding problems).

comment:2 Changed 7 years ago by David Schultz

Commits r157654/IceCube and r2958/IceTray fix some alignment/padding issues that were simple and not mentioned above.

comment:3 Changed 7 years ago by David Schultz

Attempted a PGO build on a slimmed down offline-software, using the tests as a benchmark. No noticeable different in test time. Likely this is because the unit tests are diverse, checking every possibility. Probably need to run only the production tests in order to make a difference.

Notes on how to PGO build:

CXXFLAGS="-fprofile-dir=$PWD/pgo -fprofile-generate=$PWD/pgo" cmake -DCMAKE_BUILD_TYPE=Release ../src
make all test-bins
./env-shell.sh make test
make clean
rm -rf CMakeCache.txt CMakeFiles
CXXFLAGS="-fprofile-dir=$PWD/pgo -fprofile-use=$PWD/pgo -fprofile-correction" cmake -DCMAKE_BUILD_TYPE=Release ../src
make

Note that -j cannot be used, a serial make is required.

Last edited 7 years ago by David Schultz (previous) (diff)

comment:4 Changed 6 years ago by Alex Olivas

  • Milestone changed from August 2017 to Autumnal Equinox 2018
  • Priority changed from minor to major

comment:5 Changed 6 years ago by Alex Olivas

  • Milestone changed from Autumnal Equinox 2018 to Winter Solstice 2018

comment:6 Changed 6 years ago by Alex Olivas

  • Owner changed from david.schultz to olivas
  • Status changed from new to assigned

comment:7 Changed 6 years ago by Alex Olivas

  • Summary changed from low-level optimizations to [offline] low-level optimizations

comment:8 Changed 6 years ago by Alex Olivas

  • Owner olivas deleted

comment:9 Changed 5 years ago by Alex Olivas

  • Milestone changed from Winter Solstice 2018 to Autumnal Equinox 2018
  • Owner set to mkarl

comment:10 Changed 5 years ago by Alex Olivas

  • Milestone changed from Autumnal Equinox 2018 to Vernal Equinox 2019

comment:11 Changed 5 years ago by Martina Karl

  • Status changed from assigned to accepted

comment:12 Changed 5 years ago by Alex Olivas

  • Summary changed from [offline] low-level optimizations to [offline] Reduce memory footprint for I3Position and I3Direction

comment:13 Changed 5 years ago by Alex Olivas

  • Milestone changed from Autumnal Equinox 2019 to Winter Solstice 2019

comment:14 Changed 4 years ago by Alex Olivas

  • Milestone changed from Winter Solstice 2019 to Vernal Equinox 2020

Want memory/resource tracking in cicada and benchmark off the Winter 2019 release.

comment:15 Changed 4 years ago by Alex Olivas

  • Milestone changed from Vernal Equinox 2020 to Summer Solstice 2020

Merged mkarl's I3Position branch to the trunk, which should reduce the memory footprint of I3Position (and by extension I3Particle). Next up are the other classes: I3Direction, I3Orientation, etc...

comment:16 Changed 4 years ago by Alex Olivas

  • Milestone changed from Summer Solstice 2020 to Autumnal Equinox 2020

Milestone Summer Solstice 2020 deleted

comment:17 Changed 4 years ago by Alex Olivas

  • Resolution set to duplicate
  • Status changed from accepted to closed

One issue was addressed so far, but the rest were broken into several tickets and scheduled for future milestones.

Note: See TracTickets for help on using tickets.