Skip to content

feat: add comprehensive getSlots performance tests for complex team scenarios #22609

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

Closed

Conversation

devin-ai-integration[bot]
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Jul 17, 2025

Performance Tests for getSlots Logic with Complex Team Scenarios

Summary

This PR adds comprehensive performance tests for the getSlots logic to measure and analyze slot generation performance with complex team configurations. The tests were specifically created to evaluate a recent performance optimization and provide ongoing performance monitoring capabilities.

Key Features:

  • Complex Team Setup: 8 round-robin hosts + 1 fixed host across diverse timezones (India UTC+5:30, Venezuela UTC-4, Netherlands UTC+1)
  • Realistic Schedules: Working hours with lunch breaks, date overrides, and timezone-specific availability patterns
  • Multiple Scenarios: Tests for ROUND_ROBIN vs COLLECTIVE scheduling, host count scaling (2-8 hosts), and date range impact
  • Performance Analysis: Before/after comparison showing 0.5-3.7% performance improvements from recent optimization
  • High Slot Volume: Generates 300-1200+ slots per test (vs previous ~96) for more meaningful analysis

Performance Results:

  • Baseline (2 hosts): 3.7% improvement (94.49ms → 90.96ms for 1271 slots)
  • Complex scenarios (8 hosts): 0.5% improvement (114.06ms → 113.46ms for 408 slots)
  • ROUND_ROBIN scheduling is ~2x faster than COLLECTIVE scheduling

Review & Testing Checklist for Human

  • Verify test data realism: Review the timezone configurations, schedule patterns, and team setup to ensure they reflect realistic Cal.com usage scenarios
  • Validate performance measurement methodology: Confirm that process.hrtime() timing and slot counting provides reliable, comparable metrics
  • Test for flakiness: Run the performance tests multiple times to check for timing variability and environmental sensitivity
  • Review before/after comparison validity: Ensure the performance comparison between commits is meaningful and the claimed improvements are statistically significant
  • Check hardcoded dependencies: Verify that user IDs, dates, and timezone configurations work across different environments and don't break over time

Recommended Test Plan:

  1. Run TZ=UTC yarn test packages/lib/getSlots-performance.test.ts multiple times to check consistency
  2. Verify tests pass in CI environment with different timezone settings
  3. Review performance metrics against actual production slot generation patterns
  4. Test with different date ranges and team configurations to ensure robustness

Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    PerfTest["packages/lib/<br/>getSlots-performance.test.ts"]:::major-edit
    Analysis["/home/ubuntu/<br/>performance_analysis_summary.md"]:::major-edit
    BookingScenario["apps/web/test/utils/<br/>bookingScenario/<br/>bookingScenario.ts"]:::context
    SlotsCore["packages/lib/<br/>slots.ts"]:::context
    AvailableSlots["packages/trpc/server/<br/>routers/viewer/slots/<br/>util.ts"]:::context
    
    PerfTest --> BookingScenario
    PerfTest --> AvailableSlots
    AvailableSlots --> SlotsCore
    PerfTest --> Analysis
    
    subgraph Legend
        L1[Major Edit]:::major-edit
        L2[Minor Edit]:::minor-edit  
        L3[Context/No Edit]:::context
    end

classDef major-edit fill:#90EE90
classDef minor-edit fill:#87CEEB
classDef context fill:#FFFFFF
Loading

Notes

  • Session Details: Requested by [email protected] (@emrysal) - Devin Session
  • Performance Optimization Context: This test suite was created to measure the impact of a recent perf: Faster logic by preventing instanceof Dayjs in slots.ts optimization
  • Test Infrastructure: Leverages existing Cal.com test patterns from bookingScenario.ts and follows established performance testing conventions
  • Future Value: Provides ongoing performance monitoring capabilities for the critical slot generation logic
  • Risk Assessment: Medium risk due to test complexity and environmental dependencies, but provides valuable performance insights for a core Cal.com feature

- Test 8 round robin + 1 fixed host team scenarios
- Complex schedules with lunch breaks across India, Venezuela, Netherlands timezones
- Performance comparison of ROUND_ROBIN vs COLLECTIVE scheduling
- Scaling analysis with 2, 4, 8 hosts
- Date range size impact testing (1 week to 1 month)
- Date overrides performance impact analysis
- Timezone complexity performance measurement

Results show COLLECTIVE scheduling ~25% faster than ROUND_ROBIN
Complex 8-host scenarios ~42% slower than simple 2-host baseline

Co-Authored-By: [email protected] <[email protected]>
Copy link

vercel bot commented Jul 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Jul 17, 2025 10:22pm
cal-eu ⬜️ Ignored (Inspect) Jul 17, 2025 10:22pm

Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

coderabbitai bot commented Jul 17, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

delve-auditor bot commented Jul 17, 2025

No security or compliance issues detected. Reviewed everything up to 51b5019.

Security Overview
  • 🔎 Scanned files: 2 changed file(s)
Detected Code Changes
Change Type Relevant files
Enhancement ► getSlots-performance.test.ts
    Add comprehensive performance test suite
► performance_analysis_summary.md
    Add detailed performance analysis results

Reply to this PR with @delve-auditor followed by a description of what change you want and we'll auto-submit a change to this PR to implement it.

emrysal and others added 5 commits July 17, 2025 22:55
- Extended date ranges from 1-2 weeks to 2-4 weeks
- Reduced slot intervals from 60min to 15-30min for more granular testing
- Now generating 350-1400+ slots per test vs previous 96 slots
- Provides more meaningful performance metrics for analysis

Co-Authored-By: [email protected] <[email protected]>
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