def _traceProgressModuleStart(current_module): optimization_logger.info_fileoutput( """\ Optimizing module '{module_name}', {remaining:d} more modules to go \ after that.""".format( module_name=current_module.getFullName(), remaining=ModuleRegistry.getRemainingModulesCount(), ), other_logger=progress_logger, ) # Progress bar and spammy tracing don't go along. if not _is_verbose: reportProgressBar( item=current_module.getFullName(), total=ModuleRegistry.getRemainingModulesCount() + ModuleRegistry.getDoneModulesCount(), update=False, ) if _progress and Options.isShowMemory(): output = "Memory usage {memory}:".format( memory=getHumanReadableProcessMemoryUsage()) memory_logger.info(output)
def _restartProgress(): closeProgressBar() global pass_count # Singleton, pylint: disable=global-statement pass_count += 1 optimization_logger.info_fileoutput("PASS %d:" % pass_count, other_logger=progress_logger) setupProgressBar( stage="PASS %d" % pass_count, unit="module", total=ModuleRegistry.getRemainingModulesCount() + ModuleRegistry.getDoneModulesCount(), )
def _restartProgress(): global pass_count # Singleton, pylint: disable=global-statement closeProgressBar() pass_count += 1 optimization_logger.info_fileoutput("PASS %d:" % pass_count, other_logger=progress_logger) if not Options.is_verbose or optimization_logger.isFileOutput(): setupProgressBar( stage="PASS %d" % pass_count, unit="module", total=ModuleRegistry.getRemainingModulesCount() + ModuleRegistry.getDoneModulesCount(), min_total=last_total, )
def optimizeCompiledPythonModule(module): optimization_logger.info_fileoutput( "Doing module local optimizations for '{module_name}'.".format( module_name=module.getFullName()), other_logger=progress_logger, ) touched = False if _progress and Options.isShowMemory(): memory_watch = MemoryWatch() # Temporary workaround, since we do some optimization based on the last pass results # that are then not yet fully seen in the traces yet until another time around, we # allow to continue the loop even without changes one more time. unchanged_count = 0 while True: tag_set.clear() try: # print("Compute module") with withChangeIndicationsTo(signalChange): scopes_were_incomplete = module.computeModule() except BaseException: general.info("Interrupted while working on '%s'." % module) raise if scopes_were_incomplete: tag_set.add("var_usage") Graphs.onModuleOptimizationStep(module) # Ignore other modules brought into the game. if "new_code" in tag_set: tag_set.remove("new_code") # Search for local change tags. if not tag_set: unchanged_count += 1 if unchanged_count == 1 and pass_count == 1: optimization_logger.info_fileoutput( "No changed, but retrying one more time.", other_logger=progress_logger, ) continue optimization_logger.info_fileoutput("Finished with the module.", other_logger=progress_logger) break unchanged_count = 0 optimization_logger.info_fileoutput( "Not finished with the module due to following change kinds: %s" % ",".join(sorted(tag_set)), other_logger=progress_logger, ) # Otherwise we did stuff, so note that for return value. touched = True if _progress and Options.isShowMemory(): memory_watch.finish() memory_logger.info( "Memory usage changed during optimization of '%s': %s" % (module.getFullName(), memory_watch.asStr())) Plugins.considerImplicitImports(module=module, signal_change=signalChange) return touched
def optimizeCompiledPythonModule(module): optimization_logger.info_fileoutput( "Doing module local optimizations for '{module_name}'.".format( module_name=module.getFullName() ), other_logger=progress_logger, ) touched = False if _progress and Options.isShowMemory(): memory_watch = MemoryWatch() while True: tag_set.clear() try: # print("Compute module") changed = module.computeModule() except BaseException: general.info("Interrupted while working on '%s'." % module) raise if changed: tag_set.add("var_usage") Graphs.onModuleOptimizationStep(module) # Search for local change tags. for tag in tag_set: if tag == "new_code": continue break else: optimization_logger.info_fileoutput( "Finished with the module.", other_logger=progress_logger ) break if "new_code" in tag_set: tag_set.remove("new_code") optimization_logger.info_fileoutput( "Not finished with the module due to following change kinds: %s" % ",".join(sorted(tag_set)), other_logger=progress_logger, ) # Otherwise we did stuff, so note that for return value. touched = True if _progress and Options.isShowMemory(): memory_watch.finish() memory_logger.info( "Memory usage changed during optimization of '%s': %s" % (module.getFullName(), memory_watch.asStr()) ) Plugins.considerImplicitImports(module=module, signal_change=signalChange) return touched