Skip to content
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

Add benchmark for high pin_subpackage count recipe #5246

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 148 additions & 0 deletions tests/test-recipes/metadata/_pin_subpackage_benchmark/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
# Performance regression test for https://github.com/conda/conda-build/pull/5224
# This is a reduced version of
# https://github.com/conda-forge/arrow-cpp-feedstock/blob/e6f573674c5f9c35c6a614a1563b2fe3eeb3e72b/recipe/meta.yaml
# stripped of everything apart from the large number of inter-output
# pin_subpackage dependencies/run_exports.
# Addendum: Omit libarrow-all, pyarrow, pyarrow-tests to reduce benchmark duration.

package:
name: apache-arrow
version: 15.0.2

outputs:
# - name: libarrow-all
# build:
# run_exports:
# - {{ pin_subpackage("libarrow", max_pin="x") }}
# - {{ pin_subpackage("libarrow-acero", max_pin="x") }}
# - {{ pin_subpackage("libarrow-dataset", max_pin="x") }}
# - {{ pin_subpackage("libarrow-flight", max_pin="x") }}
# - {{ pin_subpackage("libarrow-flight-sql", max_pin="x") }}
# - {{ pin_subpackage("libarrow-gandiva", max_pin="x") }}
# - {{ pin_subpackage("libarrow-substrait", max_pin="x") }}
# - {{ pin_subpackage("libparquet", max_pin="x") }}
# requirements:
# host:
# - {{ pin_subpackage("libarrow", exact=True) }}
# - {{ pin_subpackage("libarrow-acero", exact=True) }}
# - {{ pin_subpackage("libarrow-dataset", exact=True) }}
# - {{ pin_subpackage("libarrow-flight", exact=True) }}
# - {{ pin_subpackage("libarrow-flight-sql", exact=True) }}
# - {{ pin_subpackage("libarrow-gandiva", exact=True) }}
# - {{ pin_subpackage("libarrow-substrait", exact=True) }}
# - {{ pin_subpackage("libparquet", exact=True) }}
# run:
# - {{ pin_subpackage("libarrow", exact=True) }}
# - {{ pin_subpackage("libarrow-acero", exact=True) }}
# - {{ pin_subpackage("libarrow-dataset", exact=True) }}
# - {{ pin_subpackage("libarrow-flight", exact=True) }}
# - {{ pin_subpackage("libarrow-flight-sql", exact=True) }}
# - {{ pin_subpackage("libarrow-gandiva", exact=True) }}
# - {{ pin_subpackage("libarrow-substrait", exact=True) }}
# - {{ pin_subpackage("libparquet", exact=True) }}

- name: libarrow
build:
run_exports:
- {{ pin_subpackage("libarrow", max_pin="x") }}

- name: libarrow-acero
build:
run_exports:
- {{ pin_subpackage("libarrow-acero", max_pin="x") }}
requirements:
host:
- {{ pin_subpackage("libarrow", exact=True) }}
run:
- {{ pin_subpackage("libarrow", exact=True) }}

- name: libarrow-dataset
build:
run_exports:
- {{ pin_subpackage("libarrow-dataset", max_pin="x") }}
requirements:
host:
- {{ pin_subpackage("libarrow", exact=True) }}
- {{ pin_subpackage("libarrow-acero", exact=True) }}
- {{ pin_subpackage("libparquet", exact=True) }}
run:
- {{ pin_subpackage("libarrow", exact=True) }}
- {{ pin_subpackage("libarrow-acero", exact=True) }}
- {{ pin_subpackage("libparquet", exact=True) }}

- name: libarrow-flight
build:
run_exports:
- {{ pin_subpackage("libarrow-flight", max_pin="x") }}
requirements:
run:
- {{ pin_subpackage("libarrow", exact=True) }}

- name: libarrow-flight-sql
build:
run_exports:
- {{ pin_subpackage("libarrow-flight-sql", max_pin="x") }}
requirements:
host:
- {{ pin_subpackage("libarrow", exact=True) }}
- {{ pin_subpackage("libarrow-flight", exact=True) }}
run:
- {{ pin_subpackage("libarrow", exact=True) }}
- {{ pin_subpackage("libarrow-flight", exact=True) }}

- name: libarrow-gandiva
build:
run_exports:
- {{ pin_subpackage("libarrow-gandiva", max_pin="x") }}
requirements:
build:
host:
- {{ pin_subpackage("libarrow", max_pin="x") }}
run:
- {{ pin_subpackage("libarrow", exact=True) }}

- name: libarrow-substrait
build:
run_exports:
- {{ pin_subpackage("libarrow-substrait", max_pin="x") }}
requirements:
host:
- {{ pin_subpackage("libarrow", exact=True) }}
- {{ pin_subpackage("libarrow-acero", exact=True) }}
- {{ pin_subpackage("libarrow-dataset", exact=True) }}
run:
- {{ pin_subpackage("libarrow", exact=True) }}
- {{ pin_subpackage("libarrow-acero", exact=True) }}
- {{ pin_subpackage("libarrow-dataset", exact=True) }}

- name: libparquet
build:
run_exports:
- {{ pin_subpackage("libparquet", max_pin="x") }}
requirements:
host:
- {{ pin_subpackage("libarrow", max_pin="x") }}
run:
- {{ pin_subpackage("libarrow", exact=True) }}

# - name: pyarrow
# requirements:
# host:
# - {{ pin_subpackage("libarrow-all", exact=True) }}
# run:
# - {{ pin_subpackage("libarrow", exact=True) }}
# - {{ pin_subpackage("libarrow-acero", exact=True) }}
# - {{ pin_subpackage("libarrow-dataset", exact=True) }}
# - {{ pin_subpackage("libarrow-flight", exact=True) }}
# - {{ pin_subpackage("libarrow-flight-sql", exact=True) }}
# - {{ pin_subpackage("libarrow-gandiva", exact=True) }}
# - {{ pin_subpackage("libarrow-substrait", exact=True) }}
# - {{ pin_subpackage("libparquet", exact=True) }}
#
# - name: pyarrow-tests
# requirements:
# host:
# - {{ pin_subpackage("libarrow-all", exact=True) }}
# - {{ pin_subpackage('pyarrow', exact=True) }}
# run:
# - {{ pin_subpackage('pyarrow', exact=True) }}
34 changes: 34 additions & 0 deletions tests/test_api_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import os
import re
from itertools import count, islice

import pytest
import yaml
Expand All @@ -15,6 +16,7 @@

from conda_build import api, render
from conda_build.conda_interface import cc_conda_build
from conda_build.variants import validate_spec

from .utils import metadata_dir, variants_dir

Expand Down Expand Up @@ -299,3 +301,35 @@ def test_pin_expression_works_with_python_prereleases(testing_config):
assert len(ms) == 2
m = next(m_[0] for m_ in ms if m_[0].meta["package"]["name"] == "bar")
assert "python >=3.10.0rc1,<3.11.0a0" in m.meta["requirements"]["run"]


@pytest.mark.benchmark
def test_pin_subpackage_benchmark(testing_config):
# Performance regression test for https://github.com/conda/conda-build/pull/5224
recipe = os.path.join(metadata_dir, "_pin_subpackage_benchmark")

# Create variant config of size comparable (for subdir linux-64) to
# https://github.com/conda-forge/conda-forge-pinning-feedstock/blob/3c7d60f56a8cb7d1b8f5a8da0b02ae1f1f0982d7/recipe/conda_build_config.yaml
# Addendum: Changed number of single-value keys from 327 to 33 to reduce benchmark duration.
def create_variants():
# ("pkg_1, ("1.1", "1.2", ...)), ("pkg_2", ("2.1", "2.2", ...)), ...
packages = ((f"pkg_{i}", (f"{i}.{j}" for j in count(1))) for i in count(1))
variant = {}
variant["zip_keys"] = []
for version_count, package_count in [(1, 4), (4, 3), (4, 3)]:
zipped = []
for package, versions in islice(packages, package_count):
zipped.append(package)
variant[package] = list(islice(versions, version_count))
variant["zip_keys"].append(zipped)
# for version_count, package_count in [(3, 1), (2, 4), (1, 327)]:
for version_count, package_count in [(3, 1), (2, 4), (1, 33)]:
for package, versions in islice(packages, package_count):
variant[package] = list(islice(versions, version_count))
Comment on lines +319 to +328
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To simplify things, it would probably suffice only add the single-entry keys since their number is far greater than the other entries (and zip_keys).
As is, these numbers just closely recreate those from conda-forge's cbc.yaml.
(Overall, the impact on the variant size mostly affects the .config.Config.copy impact on the overall run time, I'd assume.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I say we leave this for now, we can always simplify it later once we've achieved some speedup.

validate_spec("<generated>", variant)
return variant

ms = api.render(
recipe, config=testing_config, channels=[], variants=create_variants()
)
assert len(ms) == 11 - 3 # omits libarrow-all, pyarrow, pyarrow-tests
Loading