Improve memory usage of V3Partition. Only performance change intended.

This commit is contained in:
Wilson Snyder 2021-11-03 22:01:27 -04:00
parent c1d7bfa617
commit da5644211f

View File

@ -705,8 +705,11 @@ public:
// Information associated with scoreboarding an MTask // Information associated with scoreboarding an MTask
class MergeCandidate VL_NOT_FINAL { class MergeCandidate VL_NOT_FINAL {
private: private:
bool m_removedFromSb = false; // Not on scoreboard, generally ignore // This structure is extremely hot. To save 8 bytes we pack
vluint64_t m_id; // Serial number for ordering // one bit indicating removedFromSb with the id.
vluint64_t m_id; // <63> removed, <62:0> Serial number for ordering
static constexpr vluint64_t REMOVED_MASK = 1ULL << 63;
public: public:
// CONSTRUCTORS // CONSTRUCTORS
MergeCandidate() { MergeCandidate() {
@ -717,9 +720,11 @@ public:
virtual ~MergeCandidate() = default; virtual ~MergeCandidate() = default;
virtual bool mergeWouldCreateCycle() const = 0; virtual bool mergeWouldCreateCycle() const = 0;
// METHODS // METHODS
bool removedFromSb() const { return m_removedFromSb; } bool removedFromSb() const { return (m_id & REMOVED_MASK) != 0; }
void removedFromSb(bool removed) { m_removedFromSb = removed; } void removedFromSb(bool removed) { m_id |= REMOVED_MASK; }
bool operator<(const MergeCandidate& other) const { return m_id < other.m_id; } bool operator<(const MergeCandidate& other) const {
return (m_id & ~REMOVED_MASK) < (other.m_id & ~REMOVED_MASK);
}
}; };
// A pair of associated LogicMTask's that are merge candidates for sibling // A pair of associated LogicMTask's that are merge candidates for sibling