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

[card-cache] optimizations to avoid deadlocks #420

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

Conversation

valayDave
Copy link
Contributor

@valayDave valayDave commented Apr 15, 2024

[card-cache] optimizations to avoid deadlocks

  • deadlocks happened when cleanups coincided with heavy load
  • tests simulating a cleanup (disk + shared-objects) and heavy load together were successfully able to reproduce the deadlock situation
  • Locking at the context level:
    • Each time we want to clean up we lock to create a new context
    • All directories/processes are written within that new context.
    • Switching this context which ensure that all new processes get created differently and the cleanup process can safely remove everything.
    • Context also sets the read/write directory for the cache object used in the API endpoint.
    • All locking on the API side now always time-bound. The code time's out if it can't acquire a lock.
    • The method ensure that all operations won't in-definately hold the lock.
  • Changed defaults for minimum amount to time to wait for cards in the cache process to 20 seconds (helps make things snappier)
  • Added timings dict in card cache to optimize loading cycles (Ensured that it is set based on a per-card basis)

@valayDave valayDave force-pushed the cards/cache-optimizations-2 branch 2 times, most recently from 5e44d02 to 7776685 Compare April 15, 2024 00:52
- deadlocks happened when cleanups coincided with heavy load
- tests simulating a cleanup (disk + shared-objects) and heavy load together were successfully able to reproduce the deadlock situation
- Locking at the `context` level:
    - Each time we want to clean up we lock to create a new context
    - All directories/processes are written within that new context.
    - Switching this context which ensure that all new processes get created differently and the cleanup process can safely remove everything.
    - Context also sets the read/write directory for the cache object used in the API endpoint.
    - All locking on the API side now always time-bound. The code time's out if it can't acquire a lock.
    - The method ensure that all operations won't in-definately hold the lock.
- Changed defaults for minimum amount to time to wait for cards in the cache process to 20 seconds (helps make things snappier)
- Added `timings` dict in card cache to optimize loading cycles (Ensured that it is set based on a per-card basis)
if cards is None:
return web.Response(
content_type="text/html",
status=404,
body="Card not found for task. Possibly still being processed. Please refresh page to check again.",
body=html_reload_script,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change to UI coming soon!.

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.

None yet

1 participant