Using ASSUME in place of ASSERT in non-assert builds - Mailing list pgsql-hackers

From Benjamin Coutu
Subject Using ASSUME in place of ASSERT in non-assert builds
Date
Msg-id 81a3b62b5cdf97b74f30@zeyos.com
Whole thread Raw
Responses Re: Using ASSUME in place of ASSERT in non-assert builds
Re: Using ASSUME in place of ASSERT in non-assert builds
List pgsql-hackers
Hello,

I noticed that Andres recently introduced pg_assume into the codebase - great addition!

That got me thinking: some projects (like PHP) map the ASSERT macro to ASSUME in non-assert builds. The rationale is
thatASSERT typically expresses a tautology, something the programmer believes to be always true. So in builds where
assertionsare compiled out, we can still pass that information to the optimizer via ASSUME.
 

This approach has the advantage of keeping the semantics consistent: developers write ASSERT(...) as usual, and the
compilereither enforces it at runtime (assert builds) or uses it as a hint (non-assert builds). There's no need to
writeseparate logic or macros depending on build type. And we get the benefits of both safety and optimization.
 

Was this strategy considered before introducing pg_assume, or did I miss that part of the discussion?

Cheers

-- 

Benjamin Coutu
http://www.zeyos.com



pgsql-hackers by date:

Previous
From: Bertrand Drouvot
Date:
Subject: Re: Adding basic NUMA awareness
Next
From: Mihail Nikalayeu
Date:
Subject: Re: Revisiting {CREATE INDEX, REINDEX} CONCURRENTLY improvements