nextcloud / nextcloud/spreed

Performance profiling integration tests

Open
#6,983 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement pending documentation performance 🚀 technical debt
Dominant language
PHP
Stars
2.2k
Forks
587
Avg merge
18h 27m
Merged PRs (30d)
333

Description

Here are some little steps I take to create a query log of integration tests in Talk.

🚧 Setup

  1. To speed it up and decrease setup time apply the following patch. It will make sure users are not deleted and recreated with each test which heavily improves the speed of tests in case of rerunning and also removes setup queries from your profiling:
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index 126e15258..ae89d7015 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -200,15 +200,15 @@ class FeatureContext implements Context, SnippetAcceptingContext {
 	 * @AfterScenario
 	 */
 	public function tearDown() {
-		foreach ($this->createdUsers as $user) {
-			$this->deleteUser($user);
-		}
-		foreach ($this->createdGroups as $group) {
-			$this->deleteGroup($group);
-		}
-		foreach ($this->createdGuestAccountUsers as $user) {
-			$this->deleteGuestUser($user);
-		}
+//		foreach ($this->createdUsers as $user) {
+//			$this->deleteUser($user);
+//		}
+//		foreach ($this->createdGroups as $group) {
+//			$this->deleteGroup($group);
+//		}
+//		foreach ($this->createdGuestAccountUsers as $user) {
+//			$this->deleteGuestUser($user);
+//		}
 	}
 
 	/**
  1. I normally have additional files in my skeleton folder to have images etc. available when testing. In case of creating e.g. 70 users copying them takes a lot of time, so I recommend to point the skeleton either to the default directory or remove any files but the welcome.txt
  2. Make sure you have a Redis/Memcache setup and use it normally and also for file locking as well:
'memcache.locking' => '\\OC\\Memcache\\Redis',
  1. Run the integration test you want to profile once, so all users and groups are generated
  2. Make sure you have no browser tab of the server open, no desktop client connected, xdebug disabled

🏎️ Profiling

  1. Set the query_log_file in your config.php
'query_log_file' => '/var/log/nextcloud/query.log',
  1. Run the integration test again
  2. Save the result as baseline for your profiling (we have to clear some queries which are happening unrelated increasingly):
cat query.log | grep -v "oc_talk_internalsignaling" | grep -v "UPDATE \`oc_authtoken\`" > baseline.log
  1. Clear the query log:
echo "" > query.log
  1. Do some modification
  2. Run the integration test again
  3. Save the cleaned output as progress file:
cat query.log | grep -v "oc_talk_internalsignaling" | grep -v "UPDATE \`oc_authtoken\`" > progress.log
  1. Compare the 2 query logs baseline.log and progress.log with a tool, I recommend Meld

📊 Comparing results

  1. See lines dropping in Meld:
    Bildschirmfoto von 2022-03-04 12-23-08
  2. Compare query aka line counts:
cat baseline.log | wc -l
cat progress.log | wc -l
  1. Compare query aka line counts for tables of your app (find a matching prefix, e.g. all talk tables start with oc_talk_):
cat baseline.log | grep "oc_talk_" | wc -l
cat progress.log | grep "oc_talk_" | wc -l
  1. Compare query aka line counts for a single table in this case oc_talk_rooms:
cat baseline.log | grep "oc_talk_rooms" | wc -l
cat progress.log | grep "oc_talk_rooms" | wc -l

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tests/integration/features/bootstrap/FeatureContext.php and the integration test you want to profile. Follow the setup and query-log commands in the issue, including query_log_file, then determine where this profiling guidance belongs. Done means the steps are documented in the appropriate project location and can be followed to compare baseline.log with progress.log.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, redis
Domain
documentation, performance, testing
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.