Skip to content

Reduce memory usage and load time by skipping costly fingerprint generation#296

Merged
cristian-tamblay merged 1 commit into
developfrom
perf/optimize-datasets
Sep 11, 2025
Merged

Reduce memory usage and load time by skipping costly fingerprint generation#296
cristian-tamblay merged 1 commit into
developfrom
perf/optimize-datasets

Conversation

@Irozuku
Copy link
Copy Markdown
Collaborator

@Irozuku Irozuku commented Sep 11, 2025

Summary

This PR addresses excessive RAM usage and delays when uploading datasets by optimizing the initialization of DashAIDataset.

Problem

DashAIDataset inherits from HuggingFace’s Dataset class, whose constructor performs an expensive fingerprint generation step (computing a unique identifier for the dataset).
This step significantly increases both initialization time and memory usage, even though the fingerprint is not required for our custom dataset saving/loading workflow.

Fix

The solution is to manually generate a lightweight fingerprint and pass it to the super() call in DashAIDataset.
This bypasses the costly default computation, reducing memory usage and improving dataset loading speed.

Notes

The fingerprint is only used for faster reloads when using HuggingFace’s save_dataset / load_dataset APIs, which we do not use.
Therefore, this change does not affect functionality or reproducibility within our system.

@Irozuku Irozuku changed the title Reduce Memory Usage and Load Time by Skipping Costly Fingerprint Generation Reduce memory usage and load time by skipping costly fingerprint generation Sep 11, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR optimizes DashAIDataset initialization by manually generating lightweight fingerprints to avoid expensive computation performed by HuggingFace's Dataset constructor. This reduces memory usage and improves load time during dataset uploads.

  • Manual fingerprint generation using table metadata and UUID to bypass costly default computation
  • Addition of uuid import to support fingerprint creation
  • Optimization targets the initialization bottleneck without affecting functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +61 to +63
fingerprint = (
f"manual-{hash((table.num_rows, str(table.schema)))}-{str(uuid.uuid4())}"
)
Copy link

Copilot AI Sep 11, 2025

Choose a reason for hiding this comment

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

The fingerprint generation combines a deterministic hash with a random UUID, which could create inconsistency. If the goal is to bypass expensive computation while maintaining some determinism for caching, consider using only the hash of table metadata without the random UUID component.

Suggested change
fingerprint = (
f"manual-{hash((table.num_rows, str(table.schema)))}-{str(uuid.uuid4())}"
)
fingerprint = f"manual-{hash((table.num_rows, str(table.schema)))}"

Copilot uses AI. Check for mistakes.
@cristian-tamblay cristian-tamblay merged commit e449e1e into develop Sep 11, 2025
5 checks passed
@cristian-tamblay cristian-tamblay deleted the perf/optimize-datasets branch September 11, 2025 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants