-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(ingest/unity): Add Unity Catalog memory performance testing
- Loading branch information
Showing
10 changed files
with
347 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
87 changes: 87 additions & 0 deletions
87
metadata-ingestion/tests/performance/databricks/test_unity.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import logging | ||
import os | ||
from typing import Iterable, Tuple | ||
from unittest.mock import patch | ||
|
||
import humanfriendly | ||
import psutil | ||
from performance.databricks.unity_proxy_mock import UnityCatalogApiProxyMock | ||
|
||
from datahub.ingestion.api.common import PipelineContext | ||
from datahub.ingestion.api.workunit import MetadataWorkUnit | ||
from datahub.ingestion.source.unity.config import UnityCatalogSourceConfig | ||
from datahub.ingestion.source.unity.source import UnityCatalogSource | ||
from datahub.utilities.perf_timer import PerfTimer | ||
from tests.performance.data_generation import ( | ||
NormalDistribution, | ||
generate_data, | ||
generate_queries, | ||
) | ||
|
||
|
||
def run_test(): | ||
seed_metadata = generate_data( | ||
num_containers=[1, 100, 5000], | ||
num_tables=50000, | ||
num_views=10000, | ||
columns_per_table=NormalDistribution(100, 50), | ||
parents_per_view=NormalDistribution(5, 5), | ||
view_definition_length=NormalDistribution(1000, 300), | ||
) | ||
queries = generate_queries( | ||
seed_metadata, | ||
num_selects=100000, | ||
num_operations=100000, | ||
num_unique_queries=10000, | ||
num_users=1000, | ||
) | ||
proxy_mock = UnityCatalogApiProxyMock( | ||
seed_metadata, queries=queries, num_service_principals=10000 | ||
) | ||
print("Data generated") | ||
|
||
config = UnityCatalogSourceConfig( | ||
token="", workspace_url="http://localhost:1234", include_usage_statistics=False | ||
) | ||
ctx = PipelineContext(run_id="test") | ||
with patch( | ||
"datahub.ingestion.source.unity.source.UnityCatalogApiProxy", | ||
lambda *args, **kwargs: proxy_mock, | ||
): | ||
source: UnityCatalogSource = UnityCatalogSource(ctx, config) | ||
|
||
pre_mem_usage = psutil.Process(os.getpid()).memory_info().rss | ||
print(f"Test data size: {humanfriendly.format_size(pre_mem_usage)}") | ||
|
||
with PerfTimer() as timer: | ||
workunits = source.get_workunits() | ||
num_workunits, peak_memory_usage = workunit_sink(workunits) | ||
print(f"Workunits Generated: {num_workunits}") | ||
print(f"Seconds Elapsed: {timer.elapsed_seconds():.2f} seconds") | ||
|
||
print( | ||
f"Peak Memory Used: {humanfriendly.format_size(peak_memory_usage - pre_mem_usage)}" | ||
) | ||
print(source.report.aspects) | ||
|
||
|
||
def workunit_sink(workunits: Iterable[MetadataWorkUnit]) -> Tuple[int, int]: | ||
peak_memory_usage = psutil.Process(os.getpid()).memory_info().rss | ||
i: int = 0 | ||
for i, wu in enumerate(workunits): | ||
if i % 10_000 == 0: | ||
peak_memory_usage = max( | ||
peak_memory_usage, psutil.Process(os.getpid()).memory_info().rss | ||
) | ||
peak_memory_usage = max( | ||
peak_memory_usage, psutil.Process(os.getpid()).memory_info().rss | ||
) | ||
|
||
return i, peak_memory_usage | ||
|
||
|
||
if __name__ == "__main__": | ||
root_logger = logging.getLogger() | ||
root_logger.setLevel(logging.INFO) | ||
root_logger.addHandler(logging.StreamHandler()) | ||
run_test() |
Oops, something went wrong.