Conversation
This is the first of a series of commit bringing down the memory consumption of signature_internal. Memory consumption is reduced by placing buffers whose lifetime does not overlap into a union starting with thw w and w0 buffer. CBMC contracts and proofs are adjusted where necessary. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
|
Looks good to me! Confirmed CBMC passes locally with these changes. |
| requires(memory_no_alias(v1, sizeof(mld_polyveck))) | ||
| requires(memory_no_alias(v0, sizeof(mld_polyveck))) | ||
| requires(memory_no_alias(v, sizeof(mld_polyveck))) | ||
| requires(v0 == v || memory_no_alias(v, sizeof(mld_polyveck))) |
There was a problem hiding this comment.
Is it worth keeping the non-aliased version, or can we rewrite the code so it uses the aliased version everywhere?
hanno-becker
left a comment
There was a problem hiding this comment.
It looks like the CBMC runtime got quite a lot worse, from 7/7/11 to 11/15/21.
We can of course just hope for the best and merge this, but seeing that this is only the very beginning of a series of changes, I am wary that it's not going to work for long.
|
The culprit is |
hanno-becker
left a comment
There was a problem hiding this comment.
Rather than ignoring the CBMC slowdown, I'd prefer if we could spend more time in this toy-example to understand what, if anything, we can do to keep the CBMC runtime largely where it was.
@tautschnig told me that if we never use unions for data-presentation changes and set --slice-formula, it should not matter (Michael, chime in if I mispresent anything), but this example does not seem to confirm it:
CBMCFLAGS=--external-smt2-solver $(PROOF_ROOT)/lib/z3_no_bv_extract --z3
CBMCFLAGS += --slice-formula
CBMCFLAGS += --no-array-field-sensitivity
To reduce stack usage, polyveck_decompose should be able to operate on one of the outputs aliasing the input. This is already fully supported but wasn't used to ease CBMC proofs/contracts at a cost of requiring additional stack space which is undesirable. This commit is an alternative to #792 which extended the CBMC contracts to allow aliasing. This commit instead, changes the signature of the decompose functions to take 2 arguments instead of 3, where the second output also acts as and input. The corresponding poly_ and native functions are adjusted accordingly. CBMC contracts/proofs and unit tests are adjusted to the new signature. The single callsite of polyveck_decompose is adjusted. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
To reduce stack usage, polyveck_decompose should be able to operate on one of the outputs aliasing the input. This is already fully supported but wasn't used to ease CBMC proofs/contracts at a cost of requiring additional stack space which is undesirable. This commit is an alternative to #792 which extended the CBMC contracts to allow aliasing. This commit instead, changes the signature of the decompose functions to take 2 arguments instead of 3, where the second output also acts as and input. The corresponding poly_ and native functions are adjusted accordingly. CBMC contracts/proofs and unit tests are adjusted to the new signature. The single callsite of polyveck_decompose is adjusted. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
|
I've rewritten |
To reduce stack usage, polyveck_decompose should be able to operate on one of the outputs aliasing the input. This is already fully supported but wasn't used to ease CBMC proofs/contracts at a cost of requiring additional stack space which is undesirable. This commit is an alternative to #792 which extended the CBMC contracts to allow aliasing. This commit instead, changes the signature of the decompose functions to take 2 arguments instead of 3, where the second output also acts as and input. The corresponding poly_ and native functions are adjusted accordingly. CBMC contracts/proofs and unit tests are adjusted to the new signature. The single callsite of polyveck_decompose is adjusted. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
To reduce stack usage, polyveck_decompose should be able to operate on one of the outputs aliasing the input. This is already fully supported but wasn't used to ease CBMC proofs/contracts at a cost of requiring additional stack space which is undesirable. This commit is an alternative to #792 which extended the CBMC contracts to allow aliasing. This commit instead, changes the signature of the decompose functions to take 2 arguments instead of 3, where the second output also acts as and input. The corresponding poly_ and native functions are adjusted accordingly. CBMC contracts/proofs and unit tests are adjusted to the new signature. The single callsite of polyveck_decompose is adjusted. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
To reduce stack usage, polyveck_decompose should be able to operate on one of the outputs aliasing the input. This is already fully supported but wasn't used to ease CBMC proofs/contracts at a cost of requiring additional stack space which is undesirable. This commit is an alternative to #792 which extended the CBMC contracts to allow aliasing. This commit instead, changes the signature of the decompose functions to take 2 arguments instead of 3, where the second output also acts as and input. The corresponding poly_ and native functions are adjusted accordingly. CBMC contracts/proofs and unit tests are adjusted to the new signature. The single callsite of polyveck_decompose is adjusted. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
To reduce stack usage, polyveck_decompose should be able to operate on one of the outputs aliasing the input. This is already fully supported but wasn't used to ease CBMC proofs/contracts at a cost of requiring additional stack space which is undesirable. This commit is an alternative to #792 which extended the CBMC contracts to allow aliasing. This commit instead, changes the signature of the decompose functions to take 2 arguments instead of 3, where the second output also acts as and input. The corresponding poly_ and native functions are adjusted accordingly. CBMC contracts/proofs and unit tests are adjusted to the new signature. The single callsite of polyveck_decompose is adjusted. Signed-off-by: Matthias J. Kannwischer <matthias@kannwischer.eu>
This is the first of a series of commit bringing down the memory consumption of signature_internal.
Memory consumption is reduced by placing buffers whose lifetime does not overlap into a union starting with thw w and w0 buffer. CBMC contracts and proofs are adjusted where necessary.
crypto_sign_signature_internalstack usage #791-fstack-usageofsignature_internalof ML-DSA-86 reduces from 129616 to 121536 (aarch64, -Os, gcc14).