Esempio n. 1
0
    def parallel_jobs_num(self):
        """Tune the jobs num. """
        # User has the highest priority
        user_jobs_num = self.__options.jobs
        if user_jobs_num > 0:
            return user_jobs_num

        # Calculate job numbers smartly
        jobs_num = 0
        distcc_enabled = config.get_item('distcc_config', 'enabled')

        if distcc_enabled and self.build_environment.distcc_env_prepared:
            # Distcc cost doesn;t much local cpu, jobs can be quite large.
            distcc_num = len(self.build_environment.get_distcc_hosts_list())
            jobs_num = min(max(int(1.5 * distcc_num), 1), 20)
        else:
            cpu_core_num = cpu_count()
            # machines with cpu_core_num > 4 is usually shared by multiple users,
            # set an upper bound to avoid interfering other users
            jobs_num = min(2 * cpu_core_num, 8)

        if jobs_num != user_jobs_num:
            console.info('tunes the parallel jobs number(-j N) to be %d' %
                         (jobs_num))
        return jobs_num
Esempio n. 2
0
 def _build_jobs_num(self):
     """Calculate build jobs num."""
     # User has the highest priority
     jobs_num = config.get_item('global_config', 'build_jobs')
     if jobs_num > 0:
         return jobs_num
     jobs_num = self.build_accelerator.adjust_jobs_num(cpu_count())
     console.info('Adjust build jobs number(-j N) to be %d' % jobs_num)
     return jobs_num
Esempio n. 3
0
    def _get_workers_num(self):
        """get the number of thread workers. """
        cpu_count = blade_util.cpu_count()
        max_workers = max(cpu_count, _MAX_WORKER_THREADS)
        if self.num_jobs <= 1:
            return 1
        elif self.num_jobs > max_workers:
            self.num_jobs = max_workers

        return min(len(self.tests_list), self.num_jobs)
Esempio n. 4
0
 def test_jobs_num(self):
     """Calculate the number of test jobs"""
     # User has the highest priority
     jobs_num = config.get_item('global_config', 'test_jobs')
     if jobs_num > 0:
         return jobs_num
     # In distcc enabled mode, the build_jobs_num may be quiet large, but we
     # only support run test locally, so the test_jobs_num should be limited
     # by local cpu mumber.
     # WE limit the test_jobs_num to be half of build job number because test
     # may be heavier than build (may be not, perhaps).
     build_jobs_num = self.build_jobs_num()
     cpu_core_num = cpu_count()
     jobs_num = max(min(build_jobs_num, cpu_core_num) / 2, 1)
     console.info('Adjust build jobs number(-j N) to be %d' % jobs_num)
     return jobs_num
Esempio n. 5
0
    def _build_jobs_num(self):
        """Calculate build jobs num."""
        # User has the highest priority
        jobs_num = config.get_item('global_config', 'build_jobs')
        if jobs_num > 0:
            return jobs_num

        # Calculate job numbers smartly
        distcc_enabled = config.get_item('distcc_config', 'enabled')
        if distcc_enabled and self.build_environment.distcc_env_prepared:
            # Distcc doesn't cost much local cpu, jobs can be quite large.
            distcc_num = len(self.build_environment.get_distcc_hosts_list())
            jobs_num = min(max(int(1.5 * distcc_num), 1), 20)
        else:
            cpu_core_num = cpu_count()
            # machines with cpu_core_num > 8 is usually shared by multiple users,
            # set an upper bound to avoid interfering other users
            jobs_num = min(cpu_core_num, 8)
        console.info('Adjust build jobs number(-j N) to be %d' % jobs_num)
        return jobs_num
Esempio n. 6
0
    def parallel_jobs_num(self):
        """Tune the jobs num. """
        # User has the highest priority
        user_jobs_num = self.__options.jobs
        if user_jobs_num > 0:
            return user_jobs_num

        # Calculate job numbers smartly
        distcc_enabled = config.get_item('distcc_config', 'enabled')
        if distcc_enabled and self.build_environment.distcc_env_prepared:
            # Distcc doesn't cost much local cpu, jobs can be quite large.
            distcc_num = len(self.build_environment.get_distcc_hosts_list())
            jobs_num = min(max(int(1.5 * distcc_num), 1), 20)
        else:
            cpu_core_num = cpu_count()
            # machines with cpu_core_num > 4 is usually shared by multiple users,
            # set an upper bound to avoid interfering other users
            jobs_num = min(2 * cpu_core_num, 8)
        console.info('tunes the parallel jobs number(-j N) to be %d' % jobs_num)
        return jobs_num