Skip to content

Commit

Permalink
Jvm compile counter should increment for double check cache hits
Browse files Browse the repository at this point in the history
bugfix: This makes the count more accurately represents the total progress of the compile.

Testing Done:
Moved the cache out from under pants and back in before the second check.

    10:35:06 00:00         [zinc-execute]
    10:35:07 00:01           [cache]
                           No cached artifacts for 3 targets.
                           Invalidated 3 targets in 3 target partitions.> /Users/dan/4sq/pants/src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py(622)check_cache()
    -> cached_vts, uncached_vts = self.check_artifact_cache([vts])
    (Pdb) c
    .
                           Hit cache during double check for examples/src/java/org/pantsbuild/example/hello/greet:greet> /Users/dan/4sq/pants/src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py(622)check_cache()
    -> cached_vts, uncached_vts = self.check_artifact_cache([vts])
    (Pdb) c
    .
                           Hit cache during double check for examples/src/scala/org/pantsbuild/example/hello/welcome:welcome> /Users/dan/4sq/pants/src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py(622)check_cache()
    -> cached_vts, uncached_vts = self.check_artifact_cache([vts])
    (Pdb) c

                           [3/3] Compiling 1 zinc source in 1 target (examples/tests/scala/org/pantsbuild/example/hello/welcome:welcome).

Bugs closed: 2635

Reviewed at https://rbcommons.com/s/twitter/r/3188/
  • Loading branch information
Dan Harrison authored and ericzundel committed Nov 30, 2015
1 parent 30dda3a commit cdcda91
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/python/pants/backend/jvm/tasks/jvm_compile/jvm_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,19 @@ def exec_graph_key_for_target(self, compile_target):

def _create_compile_jobs(self, classpath_products, compile_contexts, extra_compile_time_classpath,
invalid_targets, invalid_vts_partitioned):
class Counter(object):
def __init__(self, size, initial=0):
self.size = size
self.count = initial

def __call__(self):
self.count += 1
return self.count

def format_length(self):
return len(str(self.size))
counter = Counter(len(invalid_vts_partitioned))

def check_cache(vts):
"""Manually checks the artifact cache (usually immediately before compilation.)
Expand All @@ -614,6 +627,7 @@ def check_cache(vts):
'Cache returned unexpected target: {} vs {}'.format(cached_vts, [vts])
)
self.context.log.info('Hit cache during double check for {}'.format(vts.target.address.spec))
counter()
return True

def should_compile_incrementally(vts):
Expand All @@ -627,19 +641,6 @@ def should_compile_incrementally(vts):
return True
return os.path.exists(compile_context.analysis_file)

class Counter(object):
def __init__(self, size, initial=0):
self.size = size
self.count = initial

def __call__(self):
self.count += 1
return self.count

def format_length(self):
return len(str(self.size))

counter = Counter(len(invalid_vts_partitioned))
def work_for_vts(vts, compile_context):
progress_message = compile_context.target.address.spec

Expand Down

0 comments on commit cdcda91

Please sign in to comment.