Apply clang-analyzer-optin.performance.Padding

This commit is contained in:
Alexey Rybalchenko 2021-09-13 14:28:53 +02:00 committed by Dennis Klein
parent 9590b5be40
commit 597d88277b

View File

@ -142,13 +142,11 @@ class Manager
, fShmVoidAlloc(fManagementSegment.get_segment_manager()) , fShmVoidAlloc(fManagementSegment.get_segment_manager())
, fShmMtx(boost::interprocess::open_or_create, std::string("fmq_" + fShmId + "_mtx").c_str()) , fShmMtx(boost::interprocess::open_or_create, std::string("fmq_" + fShmId + "_mtx").c_str())
, fRegionEventsShmCV(boost::interprocess::open_or_create, std::string("fmq_" + fShmId + "_cv").c_str()) , fRegionEventsShmCV(boost::interprocess::open_or_create, std::string("fmq_" + fShmId + "_cv").c_str())
, fRegionEventsSubscriptionActive(false)
, fNumObservedEvents(0) , fNumObservedEvents(0)
, fDeviceCounter(nullptr) , fDeviceCounter(nullptr)
, fEventCounter(nullptr) , fEventCounter(nullptr)
, fShmSegments(nullptr) , fShmSegments(nullptr)
, fShmRegions(nullptr) , fShmRegions(nullptr)
, fInterrupted(false)
#ifdef FAIRMQ_DEBUG_MODE #ifdef FAIRMQ_DEBUG_MODE
, fMsgDebug(nullptr) , fMsgDebug(nullptr)
, fShmMsgCounters(nullptr) , fShmMsgCounters(nullptr)
@ -156,6 +154,8 @@ class Manager
, fMsgCounterDelete(0) , fMsgCounterDelete(0)
#endif #endif
, fBeatTheHeart(true) , fBeatTheHeart(true)
, fRegionEventsSubscriptionActive(false)
, fInterrupted(false)
, fThrowOnBadAlloc(config ? config->GetProperty<bool>("shm-throw-bad-alloc", true) : true) , fThrowOnBadAlloc(config ? config->GetProperty<bool>("shm-throw-bad-alloc", true) : true)
, fNoCleanup(config ? config->GetProperty<bool>("shm-no-cleanup", false) : false) , fNoCleanup(config ? config->GetProperty<bool>("shm-no-cleanup", false) : false)
{ {
@ -807,7 +807,6 @@ class Manager
boost::interprocess::named_condition fRegionEventsShmCV; boost::interprocess::named_condition fRegionEventsShmCV;
std::thread fRegionEventThread; std::thread fRegionEventThread;
bool fRegionEventsSubscriptionActive;
std::function<void(fair::mq::RegionInfo)> fRegionEventCallback; std::function<void(fair::mq::RegionInfo)> fRegionEventCallback;
std::map<std::pair<uint16_t, bool>, RegionEvent> fObservedRegionEvents; // pair: <region id, managed> std::map<std::pair<uint16_t, bool>, RegionEvent> fObservedRegionEvents; // pair: <region id, managed>
uint64_t fNumObservedEvents; uint64_t fNumObservedEvents;
@ -817,26 +816,26 @@ class Manager
Uint16SegmentInfoHashMap* fShmSegments; Uint16SegmentInfoHashMap* fShmSegments;
Uint16RegionInfoHashMap* fShmRegions; Uint16RegionInfoHashMap* fShmRegions;
std::unordered_map<uint16_t, std::unique_ptr<Region>> fRegions; std::unordered_map<uint16_t, std::unique_ptr<Region>> fRegions;
// make sure this is alone in the cache line: mostly read inline static std::atomic<unsigned long> fRegionsGen = 0ul;
alignas(128) inline static std::atomic<unsigned long> fRegionsGen = 0ul;
inline static thread_local struct ManagerTLCache { inline static thread_local struct ManagerTLCache {
unsigned long fRegionsTLCacheGen; unsigned long fRegionsTLCacheGen;
std::vector<std::tuple<Region*, uint16_t, uint64_t>> fRegionsTLCache; std::vector<std::tuple<Region*, uint16_t, uint64_t>> fRegionsTLCache;
} fTlRegionCache; } fTlRegionCache;
std::atomic<bool> fInterrupted;
#ifdef FAIRMQ_DEBUG_MODE #ifdef FAIRMQ_DEBUG_MODE
// make sure the counters are not thrashing the cache line between threads doing creation and deallocation
Uint16MsgDebugMapHashMap* fMsgDebug; Uint16MsgDebugMapHashMap* fMsgDebug;
Uint16MsgCounterHashMap* fShmMsgCounters; Uint16MsgCounterHashMap* fShmMsgCounters;
alignas(128) std::atomic_uint64_t fMsgCounterNew; std::atomic_uint64_t fMsgCounterNew;
alignas(128) std::atomic_uint64_t fMsgCounterDelete; std::atomic_uint64_t fMsgCounterDelete;
#endif #endif
std::thread fHeartbeatThread; std::thread fHeartbeatThread;
bool fBeatTheHeart;
std::mutex fHeartbeatsMtx; std::mutex fHeartbeatsMtx;
std::condition_variable fHeartbeatsCV; std::condition_variable fHeartbeatsCV;
bool fBeatTheHeart;
bool fRegionEventsSubscriptionActive;
std::atomic<bool> fInterrupted;
bool fThrowOnBadAlloc; bool fThrowOnBadAlloc;
bool fNoCleanup; bool fNoCleanup;