Skip to content

shrink Clause memory footprint by fiddling with layout#831

Merged
quickbeam123 merged 1 commit intomasterfrom
michael-clause-diet
Mar 25, 2026
Merged

shrink Clause memory footprint by fiddling with layout#831
quickbeam123 merged 1 commit intomasterfrom
michael-clause-diet

Conversation

@MichaelRawson
Copy link
Copy Markdown
Contributor

On my machine this shrinks sizeof(Clause) from 104 bytes to 88. This is done partially by @mezpusz's tip that _XXnarrows and _reductions are no longer used, but also by moving some fields around. I'll explain the changes in comments inline.

protected:
/** number of literals */
unsigned _length : 20;
unsigned _length;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shrinking this from 32 bytes to 20 doesn't help in the wider picture of things.

/** for splitting: timestamp marking when has the clause been reduced or restored by splitting */
unsigned _reductionTimestamp;
/** a map that translates Literal* to its index in the clause */
InverseLookup<Literal>* _literalPositions;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needed to be aligned to 8 bytes because it's a pointer, so the compiler generates some padding. Move things around so that it's already 8-byte aligned.

/** age */
unsigned _age;

SplitSet* _splits;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointers have to be 8-byte aligned. Move them to the start of the class because removing _XXnarrows and _reductions now throws us off.

/** Sine level computed in SineUtils and used in various heuristics.
* May stay uninitialized (i.e. always MAX), if not needed
**/
unsigned char _sineLevel : 8; // updated as the minimum from parents to children
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things that already bytes may as well stay on byte boundaries so the machine can manipulate them (mostly) without shifts.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!


/** Number of this unit, used for printing and statistics */
unsigned _number;
unsigned _number : 29;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 2^29 sufficient for numbers? We'd need roughly half a billion units to overflow this.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be enough for our current use cases ...

@quickbeam123
Copy link
Copy Markdown
Collaborator

A -sa otter -s 1010 -sac on -tgt ground -t 3 goes from 9214 unsat to 9219 (solving 130 sat each, but are talking an incomplete strategy).

Let me see how we proceed if we also remove _weight...

@quickbeam123 quickbeam123 merged commit 0a735e7 into master Mar 25, 2026
2 checks passed
@quickbeam123 quickbeam123 deleted the michael-clause-diet branch March 25, 2026 15:06
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.

3 participants