
from tests.util.cluster_controller import ClusterController
from tests.benchmark.plugins import Plugin

class ClearBufferCache(Plugin):
  """Plugin that clears the buffer cache before a query is run."""

  __name__ = "ClearBufferCache"

  def __init__(self, *args, **kwargs):
    self.cluster_controller = ClusterController(*args, **kwargs)
    Plugin.__init__(self, *args, **kwargs)

  def run_pre_hook(self, context=None):
    cmd = "sysctl -w vm.drop_caches=3 vm.drop_caches=0"
    self.cluster_controller.run_cmd(cmd)


from tests.util.cluster_controller import ClusterController
from tests.benchmark.plugins import Plugin

class ClearBufferCache(Plugin):
  """Plugin that clears the buffer cache before a query is run."""

  __name__ = "ClearBufferCache"

  def __init__(self, *args, **kwargs):
    self.cluster_controller = ClusterController(*args, **kwargs)
    Plugin.__init__(self, *args, **kwargs)

  def run_pre_hook(self, context=None):
    # Drop the page cache (drop_caches=1). We'll leave the inodes and dentries
    # since that is not what we are testing and it causes excessive performance
    # variability.
    cmd = "sysctl -w vm.drop_caches=1 vm.drop_caches=0"
    self.cluster_controller.run_cmd(cmd)

Update clear buffer cache plugin to only flush page cache.
Update clear buffer cache plugin to only flush page cache.

More detail: http://linux-mm.org/Drop_Caches

Change-Id: I7fa675ccdc81f375d88e9cfab330fca3bc983ec8
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1157
Reviewed-by: Alex Behm <fe1626037acfc2dc542d2aa723a6d14f2464a20c@cloudera.com>
Reviewed-by: Lenni Kuff <724b7df200764f5dc1b723c05ee6c6adabd11bb1@cloudera.com>
Tested-by: Nong Li <99a5e5f8f5911755b88e0b536d46aafa102bed41@cloudera.com>

  
  from tests.util.cluster_controller import ClusterController
  from tests.benchmark.plugins import Plugin
  
  class ClearBufferCache(Plugin):
    """Plugin that clears the buffer cache before a query is run."""
  
    __name__ = "ClearBufferCache"
  
    def __init__(self, *args, **kwargs):
      self.cluster_controller = ClusterController(*args, **kwargs)
      Plugin.__init__(self, *args, **kwargs)
  
    def run_pre_hook(self, context=None):
+     # Drop the page cache (drop_caches=1). We'll leave the inodes and dentries
+     # since that is not what we are testing and it causes excessive performance
+     # variability.
-     cmd = "sysctl -w vm.drop_caches=3 vm.drop_caches=0"
+     cmd = "sysctl -w vm.drop_caches=1 vm.drop_caches=0"
      self.cluster_controller.run_cmd(cmd)
  
Update clear buffer cache plugin to only flush page cache.
## Code Before:

from tests.util.cluster_controller import ClusterController
from tests.benchmark.plugins import Plugin

class ClearBufferCache(Plugin):
  """Plugin that clears the buffer cache before a query is run."""

  __name__ = "ClearBufferCache"

  def __init__(self, *args, **kwargs):
    self.cluster_controller = ClusterController(*args, **kwargs)
    Plugin.__init__(self, *args, **kwargs)

  def run_pre_hook(self, context=None):
    cmd = "sysctl -w vm.drop_caches=3 vm.drop_caches=0"
    self.cluster_controller.run_cmd(cmd)

## Instruction:
Update clear buffer cache plugin to only flush page cache.
## Code After:

from tests.util.cluster_controller import ClusterController
from tests.benchmark.plugins import Plugin

class ClearBufferCache(Plugin):
  """Plugin that clears the buffer cache before a query is run."""

  __name__ = "ClearBufferCache"

  def __init__(self, *args, **kwargs):
    self.cluster_controller = ClusterController(*args, **kwargs)
    Plugin.__init__(self, *args, **kwargs)

  def run_pre_hook(self, context=None):
    # Drop the page cache (drop_caches=1). We'll leave the inodes and dentries
    # since that is not what we are testing and it causes excessive performance
    # variability.
    cmd = "sysctl -w vm.drop_caches=1 vm.drop_caches=0"
    self.cluster_controller.run_cmd(cmd)
