-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
test(ingest/unity): Add Unity Catalog memory performance testing #8932
Merged
asikowitz
merged 2 commits into
datahub-project:master
from
asikowitz:unity-memory-testing
Oct 4, 2023
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]: | ||
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. this looks like copied code - any chance we could refactor some of the common logic out? 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. Nice catch |
||
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
these imports should be
tests.performance...