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 createModuleTree(module, source_ref, source_code, is_main): if Options.isShowMemory(): memory_watch = MemoryUsage.MemoryWatch() try: module_body = buildParseTree( provider=module, source_code=source_code, source_ref=source_ref, is_module=True, is_main=is_main, ) except RuntimeError as e: if "maximum recursion depth" in e.args[0]: raise CodeTooComplexCode(module.getFullName(), module.getCompileTimeFilename()) raise if module_body.isStatementsFrame(): module_body = makeStatementsSequenceFromStatement( statement=module_body) module.setChild("body", module_body) completeVariableClosures(module) if Options.isShowMemory(): memory_watch.finish() memory_logger.info("Memory usage changed loading module '%s': %s" % (module.getFullName(), memory_watch.asStr()))
def createModuleTree(module, source_ref, ast_tree, is_main): if Options.isShowMemory(): memory_watch = MemoryUsage.MemoryWatch() module_body = buildParseTree( provider=module, ast_tree=ast_tree, source_ref=source_ref, is_module=True, is_main=is_main, ) if module_body.isStatementsFrame(): module_body = makeStatementsSequenceFromStatement( statement=module_body) module.setChild("body", module_body) completeVariableClosures(module) if Options.isShowMemory(): memory_watch.finish() memory_logger.info("Memory usage changed loading module '%s': %s" % (module.getFullName(), memory_watch.asStr()))
def optimizeCompiledPythonModule(module): if _progress: progress_logger.info( "Doing module local optimizations for '{module_name}'.".format( module_name=module.getFullName())) touched = False if _progress and Options.isShowMemory(): memory_watch = MemoryUsage.MemoryWatch() while True: tag_set.clear() try: # print("Compute module") module.computeModule() except BaseException: general.info("Interrupted while working on '%s'." % module) raise Graphs.onModuleOptimizationStep(module) # Search for local change tags. for tag in tag_set: if tag == "new_code": continue break else: if _progress: progress_logger.info("Finished with the module.") break if _progress: if "new_code" in tag_set: tag_set.remove("new_code") progress_logger.info( "Not finished with the module due to following change kinds: %s" % ",".join(sorted(tag_set))) # 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 _traceProgress(current_module): output = """\ Optimizing module '{module_name}', {remaining:d} more modules to go \ after that.""".format( module_name=current_module.getFullName(), remaining=ModuleRegistry.remainingCount(), ) progress_logger.info(output) if Options.isShowMemory(): output = "Memory usage {memory}:".format( memory=MemoryUsage.getHumanReadableProcessMemoryUsage()) memory_logger.info(output)
def _traceProgress(current_module): if _progress: output = """\ Optimizing module '{module_name}', {remaining:d} more modules to go \ after that.""".format( module_name=current_module.getFullName(), remaining=ModuleRegistry.getRemainingModulesCount(), ) progress_logger.info(output) reportProgressBar( stage="Optimization", unit=" modules", item=current_module.getFullName(), total=ModuleRegistry.getRemainingModulesCount() + ModuleRegistry.getDoneModulesCount(), ) if _progress and Options.isShowMemory(): output = "Memory usage {memory}:".format( memory=getHumanReadableProcessMemoryUsage()) memory_logger.info(output)
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