Skip to content

Conversation

@ad-m-ss
Copy link

@ad-m-ss ad-m-ss commented Sep 15, 2025

Summary

  • Improves performance by avoiding redundant database comment syncing during TransactionTestCase tests
  • Adds tracking mechanism to prevent multiple comment sync operations for the same app
  • Reduces test execution time by eliminating unnecessary database operations

Problem

Django's TransactionTestCase calls flush after each test, which emits the post_migrate signal and triggers database comment syncing. This becomes expensive proportionally to the number of models, causing slower test execution.

As noted in Django docs:

After each test, Django calls flush to reset the database state. This empties all tables and emits the post_migrate signal, which recreates one content type and four permissions for each model. This operation gets expensive proportionally to the number of models.

Changes

  • Add PROCESSED_APPS global set to track apps that have already been processed
  • Check if app is already processed before syncing comments in copy_help_texts_to_database()
  • Move test_post_migrate_signal to new TestDbcommentsSignal(TransactionTestCase) class with proper test isolation
  • Add comprehensive test coverage to verify apps are not processed multiple times

Performance Impact

This change significantly improves test execution speed by preventing redundant database comment operations during test runs.

Test plan

  • Existing functionality remains unchanged
  • New test verifies single processing per app
  • TransactionTestCase properly isolated with available_apps
  • All tests continue to pass

Based on commit 693501d addressing SC-102662.

🤖 Generated with Claude Code

@ad-m-ss ad-m-ss changed the title [Perf] Skip syncing db comments for apps already synced in TransactionTestCase perf: Skip syncing db comments for apps already synced in TransactionTestCase Sep 15, 2025
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.

2 participants