Skip to content
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

GitAuto: A performance of a page (/settings/integrations/jira) is too slow. #143

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gitauto-ai[bot]
Copy link

@gitauto-ai gitauto-ai bot commented Dec 24, 2024

Resolves #133

Why the bug occurs

The /settings/integrations/jira page experiences slow performance primarily due to multiple redundant calls to the get-installed-repos API endpoint. Each call with different installationId parameters results in significant delays, cumulatively leading to an excessive page load time of approximately 15.43 seconds. This redundancy not only increases the server processing load but also leads to inefficient network utilization.

How to reproduce

  1. Navigate to the /settings/integrations/jira page in the application.
  2. Observe the network requests in the browser's developer console.
  3. Notice multiple get-installed-repos requests with different installationId values being made sequentially.
  4. The cumulative effect of these requests results in a noticeable slowdown of the page load.

Where / How to code and why

Backend Optimization

  • File: app/api/github/get-installed-repos/route.ts

    Changes:

    • Implement Caching: Introduce caching mechanisms (e.g., in-memory caching using node-cache or integrating Redis) to store responses of frequently accessed installationIds. This reduces the need for repetitive database queries and accelerates response times.

    • Batch Processing: Modify the endpoint to accept multiple installationIds in a single request, allowing the server to process and return data for all requested installations at once. This minimizes the number of API calls and reduces overall latency.

    Reasoning: Caching reduces redundant database access, and batch processing decreases the number of network requests, both of which contribute to improved performance.

Frontend Optimization

  • Files:

    • app/settings/integrations/jira/useIntegrations.ts
    • app/settings/integrations/jira/useRows.ts
    • app/settings/integrations/jira/JiraForm.tsx

    Changes:

    • Consolidate API Calls: Refactor the frontend logic to gather all necessary installationIds and make a single batched request to the optimized get-installed-repos endpoint. This can be achieved by aggregating the IDs before making the API call.

    • Implement Debouncing: Introduce debouncing strategies to prevent rapid successive calls to the API when the component mounts or when certain state changes occur.

    • Utilize SWR or React Query: Adopt data fetching libraries like SWR or React Query to handle caching, request deduplication, and automatic retries, enhancing data management and reducing unnecessary requests.

    Reasoning: Consolidating API calls reduces the number of server interactions, debouncing prevents unnecessary rapid requests, and leveraging data fetching libraries ensures efficient and optimized data handling on the frontend.

Additional Enhancements

  • Monitoring and Logging: Enhance server-side logging to monitor the performance of the get-installed-repos endpoint post-optimization. This ensures that caching and batching are functioning as intended and helps in identifying any unforeseen issues.

  • Error Handling: Improve error handling mechanisms to gracefully manage scenarios where the batched requests might fail, ensuring a better user experience.

Anything the issuer needs to do

No action required.

Test these changes locally

git fetch origin
git checkout gitauto/issue-133-20241224-000730
git pull origin gitauto/issue-133-20241224-000730

Copy link

vercel bot commented Dec 24, 2024

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

Name Status Preview Comments Updated (UTC)
gitauto-website ❌ Failed (Inspect) Dec 24, 2024 0:11am

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.

0 participants