Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-5386

Rationalize Drill's use of the Java assertions flag

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.10.0
    • None
    • None
    • None

    Description

      Java provides a very handy debugging tool: assertions:

      assert someInvariantCondition;
      

      Basically, this says that someInvariantCondition should always hold. This is a quick and easy way to validate invariants in the code.

      Assertions add overhead. To address this concern, assertions are a runtime option, and are off by default. Assertions are enabled with the -ea JVM command-line option. When off, the JVM does not evaluate the assertion, it is as if the assertion were not even in the code.

      Although assertions are well-known tools, it seems that Drill went off into two directions that compromise the usefulness of assertions.

      First, Drill uses the -ea flag to enable other, far more expensive, debugging aids as well. When assertions are enabled, the allocator performs very expensive checks and logging on each allocation and deallocation, vastly slowing execution. Second, assertions control the fault injection mechanism.

      Second, since Drill has made assertions so expensive, they are not often used. Instead, Drill uses Guava preconditions. But, these are always enabled and entail one or more function calls: much more expensive at run time than assertions.

      To address this state of affairs:

      • Detach allocator debugging from assertions. Use a config option to enable the allocator debug features. This avoids the current huge overhead of enabling assertions.
      • Similarly, use a config option to enable the fault injection mechanism so faults can be injected when Drill runs at full performance.
      • Encourage the use of Java assertions liberally in new code to allow the JVM to catch bugs so engineers don't have to do quite so much manual testing.
      • Over time, replace Guava preconditions with Java assertions to get Drill to follow normal Java practices.

      Attachments

        Activity

          People

            paul-rogers Paul Rogers
            paul-rogers Paul Rogers
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: