I hate that comment with a passion. Please please please please do yourself a favor and *always* run with asserts on. `-ea` for life. In practice I'd be surprised if you actually got a reliable 5% performance win and I doubt your customers will care about a potential 5% performance win when you've corrupted all their data.
best, kjellman > On Sep 21, 2016, at 10:21 AM, Edward Capriolo <edlinuxg...@gmail.com> wrote: > > There are a variety of assert usages in the Cassandra. You can find several > tickets like mine. > > https://issues.apache.org/jira/browse/CASSANDRA-12643 > > https://issues.apache.org/jira/browse/CASSANDRA-11537 > > Just to prove that I am not the only one who runs into these: > > https://issues.apache.org/jira/browse/CASSANDRA-12484 > > To paraphrase another ticket that I read today and can not find, > "The problem is X throws Assertion which is not caught by the Exception > handler and it bubbles over and creates a thread death." > > The jvm.properties file claims this: > > # enable assertions. disabling this in production will give a modest > # performance benefit (around 5%). > -ea > > If assertions incur a "5% penalty" but are not always trapped what value do > they add? > > These are common sentiments about how assert should be used: (not trying to > make this a this is what the internet says type debate) > > http://stackoverflow.com/questions/2758224/what-does-the-java-assert-keyword-do-and-when-should-it-be-used > > "Assertions > <http://docs.oracle.com/javase/specs/jls/se8/html/jls-14.html#jls-14.10> (by > way of the *assert* keyword) were added in Java 1.4. They are used to > verify the correctness of an invariant in the code. They should never be > triggered in production code, and are indicative of a bug or misuse of a > code path. They can be activated at run-time by way of the -eaoption on the > java command, but are not turned on by default." > > http://stackoverflow.com/questions/1957645/when-to-use-an-assertion-and-when-to-use-an-exception > > "An assertion would stop the program from running, but an exception would > let the program continue running." > > I look at how Cassandra uses assert and how it manifests in how the code > operates in production. Assert is something like semi-unchecked exception. > All types of internal Util classes might throw it, downstream code is > essentially unaware and rarely specifically handles it. They do not always > result in the hard death one would expect from an assert. > > I know this is a ballpark type figure, but would "5% performance penalty" > be in the ballpark of a checked exception? Being that they tend to bubble > through things uncaught do they do more danger than good?