-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[coverage] Automatic merger for LLVM profile data #1126
Changes from 33 commits
eb27ca1
2cf852f
c6c0b3d
32fda29
a41ec1a
78612e5
03964cc
3ea61fb
9eb729c
fb6ee1a
259af4d
c83fb1c
1b30a49
5a2a809
9fccf50
bb8160a
b4c7678
e997fc3
44be500
7608f88
b1d6e17
0e6f798
e9d009e
44e44ad
b8a2249
96d4261
1777c20
d41bd9a
f99fd75
d7eff48
693d7da
6572267
dea48f4
eb9fb9c
45df849
873af8e
f713042
c75fa76
6ec0dd3
cf30318
13bae93
2b22040
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import tempfile | ||
import os | ||
|
||
class Config(): | ||
"""A class to store configuration information specified by command-line arguments. | ||
Used to encapsulate what would normally be global variables.""" | ||
def __init__(self, debug, out_dir, no_remove_files): | ||
self.debug = debug | ||
self.out_dir = out_dir | ||
self.tmp_dir = tempfile.mkdtemp() | ||
self.pid_file_path = os.path.join(self.out_dir, "profdata_merge_worker.pid") | ||
self.final_profdata_path = os.path.join(self.out_dir, "swift.profdata") | ||
self.remove_files = not no_remove_files | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env python | ||
|
||
# utils/profdata_merge/main.py | ||
# | ||
# This source file is part of the Swift.org open source project | ||
# | ||
# Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors | ||
# Licensed under Apache License v2.0 with Runtime Library Exception | ||
# | ||
# See http://swift.org/LICENSE.txt for license information | ||
# See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors | ||
|
||
# This module is used to prevent profile data filling up available disk space | ||
# by listening for profile data and merging them into a universal profdata | ||
# file while tests are executing. | ||
# This file invokes the runner after parsing arguments. | ||
|
||
from __future__ import print_function | ||
import sys | ||
import argparse | ||
from multiprocessing import Lock | ||
|
||
import runner | ||
|
||
SERVER_ADDRESS = ('localhost', 12400) | ||
TESTS_FINISHED_SENTINEL = "PROFDATA_MERGE_WORKER_TESTS_FINISHED_SENTINEL" | ||
|
||
printlock = Lock() | ||
def printsync(msg, config): | ||
if not config.debug: | ||
return | ||
with printlock: | ||
print(msg, file=sys.stderr) | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
|
||
subparsers = parser.add_subparsers() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, I had no idea about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually found out about it in |
||
|
||
start = subparsers.add_parser("start") | ||
start.add_argument("-d", "--debug", | ||
help="Run in foreground and report status.", | ||
action="store_true") | ||
start.add_argument("-o", "--output-dir", | ||
help="The directory to write the PID file and final profdata file.", | ||
default="/tmp") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use the stdlib's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
start.add_argument("--no-remove", | ||
action="store_true", | ||
help="Don't remove profraw files after merging them.") | ||
start.set_defaults(func=runner.start_server) | ||
|
||
stop = subparsers.add_parser("stop") | ||
stop.set_defaults(func=runner.stop_server) | ||
|
||
args = parser.parse_args() | ||
args.func(args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It comes from
lit.site.cfg.in
-- CMake fills it in with the appropriate value, and it's used to determine the pre- and post-test behaviorThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, whoops! I deleted my comment too late--I had misread 😅