MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / main

Function main

tools/materialize-bench/run.py:115–211  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113
114
115def main():
116 parser = argparse.ArgumentParser(description=__doc__)
117 selection = parser.add_mutually_exclusive_group(required=True)
118 selection.add_argument('--build', action='store_true', help='build offline/locked/release from fingerprinted source')
119 selection.add_argument('--binary', type=Path, help='explicit existing materialize_bench executable (build provenance not assumed)')
120 parser.add_argument('--output', required=True, type=Path, help='new artifact directory; must not exist')
121 parser.add_argument('--profile', choices=PROFILES, default='many-files')
122 for name in ('files', 'lines', 'edits'):
123 parser.add_argument('--' + name, type=int)
124 parser.add_argument('--iterations', type=int, default=8)
125 parser.add_argument('--warmups', type=int, default=1)
126 parser.add_argument('--threads', type=int, default=2)
127 parser.add_argument('--keep-fixtures', action='store_true')
128 parser.add_argument('--allow-debug', action='store_true', help='correctness smoke only, not performance evidence')
129 args = parser.parse_args()
130 if args.threads < 1 or args.iterations < 1 or args.warmups < 0:
131 parser.error('threads/iterations must be positive and warmups nonnegative')
132 output = args.output.resolve()
133 output.mkdir(parents=True, exist_ok=False)
134 output.chmod(0o700)
135 source_before = source_fingerprint()
136 metadata = dict(outcome='incomplete', source_sha256=source_before,
137 source_binding='fingerprinted offline release build' if args.build else 'caller-supplied binary; source/build association unverified',
138 platform=platform.platform(), logical_cpus=os.cpu_count(), threads=args.threads,
139 balanced_backend_order=args.iterations % 2 == 0,
140 concurrency_control='OS cache and unrelated system load are not controlled')
141 try:
142 candidate = args.binary.resolve() if args.binary else None
143 if args.build:
144 command = ['cargo', 'build', '--release', '--offline', '--locked', '-p', 'atomic-repository',
145 '--example', 'materialize_bench', '--message-format=json-render-diagnostics']
146 build_env = dict(os.environ, CARGO_NET_OFFLINE='true')
147 build_env.setdefault('CARGO_BUILD_JOBS', '2')
148 # Avoid platform-specific stripping tools; recorded here so build
149 # settings are explicit. This changes debug stripping, not safety.
150 build_env.setdefault('CARGO_PROFILE_RELEASE_STRIP', 'none')
151 metadata['build_command'] = command
152 metadata['release_strip'] = build_env['CARGO_PROFILE_RELEASE_STRIP']
153 result = subprocess.run(command, cwd=ROOT, env=build_env, capture_output=True)
154 (output / 'build.stdout.jsonl').write_bytes(result.stdout)
155 (output / 'build.stderr.log').write_bytes(result.stderr)
156 result.check_returncode()
157 for line in result.stdout.splitlines():
158 event = json.loads(line)
159 if event.get('reason') == 'compiler-artifact' and event.get('target', {}).get('name') == 'materialize_bench' and event.get('executable'):
160 candidate = Path(event['executable'])
161 if candidate is None:
162 raise RuntimeError('Cargo did not report the benchmark executable')
163 if source_fingerprint() != source_before:
164 raise RuntimeError('source changed during build; discard this candidate')
165 if candidate is None or not candidate.is_file():
166 raise RuntimeError('benchmark executable not found')
167 binary = output / 'materialize_bench'
168 shutil.copy2(candidate, binary)
169 metadata['binary_sha256'] = digest(binary)
170 config = dict(PROFILES[args.profile])
171 config.update({name: getattr(args, name) for name in ('files', 'lines', 'edits') if getattr(args, name) is not None})
172 command = [str(binary), '--output', str(output / 'raw.json'), '--iterations', str(args.iterations),

Callers 1

run.pyFile · 0.70

Calls 11

source_fingerprintFunction · 0.85
errorMethod · 0.80
digestFunction · 0.70
validate_reportFunction · 0.70
summarizeFunction · 0.70
getMethod · 0.65
resolveMethod · 0.45
runMethod · 0.45
is_fileMethod · 0.45
updateMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected