Ejemplo n.º 1
0
 def _keepalive(self, prog):
     # Based on empirical testing. In most cases, for ~2000 IR nodes,
     # analysis takes ~1sec on a good cpu. However, depending on the
     # cyclomatic complexity of the subprogram, it can take in some cases
     # a lot more than that. Therefore, we say that it can take a maximum of
     # 40 seconds for ~2000 IR nodes.
     # todo: design some heuristics to evaluate complexity of an IR program.
     keepalive(ircount(prog) / 50.0, self.analysis_file)
Ejemplo n.º 2
0
def do_partition(args, provider_config, checkers, partition):
    """
    Runs the checkers on a single partition of the whole set of files.
    Returns a list of diagnostics.

    :param argparse.Namespace args: The command-line arguments.
    :param ProviderConfig provider_config: The provider configuration.
    :param list[(Checker, list[str])] checkers: The list of checkers to run
        together with their specific arguments.
    :param (int, list[str]) partition: The index of that partition and the list
        of files that make up that partition.
    :rtype: list[(DiagnosticPosition, str, MessageKind, str)]
    """
    set_logger(args)
    keepalive(2)

    diags = []
    index, files = partition

    logger.log('debug',
               "started partition {} with files {}".format(index, files))

    try:
        reqs = get_requirements(provider_config, checkers, files)
        schedule = get_schedules(reqs)[0]

        if args.export_schedule is not None:
            export_schedule(schedule, "{}{}".format(args.export_schedule,
                                                    index))

        for checker_result in schedule.run(on_subgoal_achieved).values():
            for program_result in checker_result:
                for diag in program_result.diagnostics:
                    report = program_result.diag_report(diag)
                    if report is not None:
                        diags.append(report)
    except Exception:
        with logger.log_stdout('internal-error'):
            traceback.print_exc(file=sys.stdout)
    finally:
        logger.log('debug', "completed partition {}".format(index))
        return diags
Ejemplo n.º 3
0
 def _keepalive(self):
     # Model generation is generally pretty fast and should not get stuck.
     # Therefore, we let it run for a safe amount of time, depending on the
     # number of files.
     keepalive(len(self.filenames))
Ejemplo n.º 4
0
 def _keepalive(self, root):
     # Based on empirical testing. For ~1500 tokens, IR generation takes
     # ~1sec on a good cpu. We add 10 seconds for libadalang to perform
     # name resolution.
     keepalive(token_count(root) / 1500.0 + 10, self.filename)
Ejemplo n.º 5
0
 def _keepalive(self):
     # Libadalang is pretty fast at parsing and will probably never get
     # stuck at this stage, so we let it do its thing for at least 10
     # seconds.
     keepalive(10, self.filename)
Ejemplo n.º 6
0
def abstract_semantics_checker_keepalive():
    # Those are extremely fast as they simply perform some trivial checks on
    # results of the analysis at a few interesting nodes in the CFG of a
    # subprogram. Typically, they will take < 0.001 seconds for a single
    # subprogram. Therefore, we safely use a 1 second timeout.
    keepalive(1)
Ejemplo n.º 7
0
def syntactic_checker_keepalive(unit):
    # Based on empirical testing. For ~5000 tokens, the syntactic checkers
    # take ~1sec on a good cpu.
    keepalive(token_count(unit.root) / 5000.0, unit.filename)