Skip to content

Commit

Permalink
Merge pull request Ericsson#4118 from vodorok/osx_and_windows_multp
Browse files Browse the repository at this point in the history
[cmd][store] Add `multiprocess`-based store to MacOS and Windows
  • Loading branch information
bruntib authored Dec 8, 2023
2 parents dc518cc + d56e216 commit 1a90030
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 35 deletions.
18 changes: 18 additions & 0 deletions codechecker_common/multiprocesspool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# -------------------------------------------------------------------------
#
# Part of the CodeChecker project, under the Apache License v2.0 with
# LLVM Exceptions. See LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#
# -------------------------------------------------------------------------
"""
Multiprocess compatibility module.
"""

import sys

# pylint: disable=unused-import
if sys.platform in ["darwin", "win32"]:
from multiprocess import Pool as MultiProcessPool
else:
from concurrent.futures import ProcessPoolExecutor as MultiProcessPool
17 changes: 4 additions & 13 deletions web/client/codechecker_client/blame_info.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import json
import os
import sys
import zipfile

from concurrent.futures import ProcessPoolExecutor
from git import Repo
from git.exc import InvalidGitRepositoryError
from typing import Dict, Iterable, Optional

from codechecker_common.logger import get_logger
from codechecker_common.multiprocesspool import MultiProcessPool

LOG = get_logger('system')

Expand Down Expand Up @@ -113,17 +112,9 @@ def assemble_blame_info(
Returns the number of collected blame information.
"""
# Currently ProcessPoolExecutor fails completely in windows.
# Reason is most likely combination of venv and fork() not
# being present in windows, so stuff like setting up
# PYTHONPATH in parent CodeChecker before store is executed
# are lost.
if sys.platform == "win32":
file_blame_info = __collect_blame_info_for_files(file_paths)
else:
with ProcessPoolExecutor() as executor:
file_blame_info = __collect_blame_info_for_files(
file_paths, executor.map)
with MultiProcessPool() as executor:
file_blame_info = __collect_blame_info_for_files(
file_paths, executor.map)

# Add blame information to the zip for the files which will be sent
# to the server if exist.
Expand Down
27 changes: 5 additions & 22 deletions web/client/codechecker_client/cmd/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import zlib

from collections import defaultdict, namedtuple
from concurrent.futures import ProcessPoolExecutor
from contextlib import contextmanager
from datetime import timedelta
from threading import Timer
Expand All @@ -46,6 +45,7 @@
from codechecker_common.source_code_comment_handler import \
SourceCodeCommentHandler
from codechecker_common.util import load_json
from codechecker_common.multiprocesspool import MultiProcessPool

from codechecker_web.shared import webserver_context, host_check
from codechecker_web.shared.env import get_default_workspace
Expand Down Expand Up @@ -371,16 +371,8 @@ def filter_source_files_with_comments(
"""
jobs = file_report_positions.items()

# Currently ProcessPoolExecutor fails completely in windows.
# Reason is most likely combination of venv and fork() not
# being present in windows, so stuff like setting up
# PYTHONPATH in parent CodeChecker before store is executed
# are lost.
if sys.platform == "win32":
return get_source_file_with_comments(jobs)
else:
with ProcessPoolExecutor() as executor:
return get_source_file_with_comments(jobs, executor.map)
with MultiProcessPool() as executor:
return get_source_file_with_comments(jobs, executor.map)


def get_reports(
Expand Down Expand Up @@ -455,18 +447,9 @@ def assemble_zip(inputs,

LOG.debug("Processing report files ...")

# Currently ProcessPoolExecutor fails completely in windows.
# Reason is most likely combination of venv and fork() not
# being present in windows, so stuff like setting up
# PYTHONPATH in parent CodeChecker before store is executed
# are lost.
if sys.platform == "win32":
with MultiProcessPool() as executor:
analyzer_result_file_reports = parse_analyzer_result_files(
analyzer_result_file_paths, checker_labels)
else:
with ProcessPoolExecutor() as executor:
analyzer_result_file_reports = parse_analyzer_result_files(
analyzer_result_file_paths, checker_labels, executor.map)
analyzer_result_file_paths, checker_labels, executor.map)

LOG.info("Processing report files done.")

Expand Down

0 comments on commit 1a90030

Please sign in to comment.