Skip to content

Conversation

@juliusknorr
Copy link
Member

@juliusknorr juliusknorr commented Apr 10, 2025

This PR adds simple profiling capabilities that can be turned on with config.php options. This is similar to what sentry already offers but in most setups that need debugging installing sentry is not something that can be achieved on short notice.

Blackfire can already be used but requires a subscription and can not sample without an extra plan.

It has two operation modes:

  1. Profile a single request

This can be either enabled for all requests (very heavy) or when sending a configured secret along the request. The files are stored using the date and request id to find them more easily.

# Set this in config php
  'profiling.secret' => 'secret',
# Send a curl request with the secret
$ curl 'https://nextcloud.local/index.php/login?profile_secret=secret'
# See the file in /tmp/profile-* 
  1. Samping the request at a configured rate

The request will be sampled to a file that can be rotated in a custom amount of time (e.g. every hour or every 5 minutes)

# Set this in config.php
  'profiling.sample' => true,
  'profiling.sample.rate' => 0.5,
# Send some requests and see the sample profile at /tmp/sample-*

The files will be just written to a configurable path (/tmp by default)

Just a quick implementation for now, this could become more sophisticated, but I used this a couple of times already as a code dump in config.php and it is really useful

https://github.com/jlfwong/speedscope can be used to plot colorful graphs

@juliusknorr juliusknorr requested a review from a team as a code owner April 10, 2025 15:08
@juliusknorr juliusknorr requested review from ArtificialOwl, ChristophWurst, icewind1991, nickvergessen and skjnldsv and removed request for a team April 10, 2025 15:08
@juliusknorr juliusknorr added performance 🚀 2. developing Work in progress 3. to review Waiting for reviews and removed 2. developing Work in progress labels Apr 10, 2025
Copy link
Member

@ChristophWurst ChristophWurst left a comment

Choose a reason for hiding this comment

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

Really good stuff 🙏 It's nice to have this built into Nextcloud

@juliusknorr juliusknorr force-pushed the perf/excimer branch 2 times, most recently from c2b4b01 to 19a695e Compare April 11, 2025 05:29
@juliusknorr juliusknorr merged commit 12490b2 into master Apr 22, 2025
191 of 198 checks passed
@juliusknorr juliusknorr deleted the perf/excimer branch April 22, 2025 12:50
@juliusknorr juliusknorr added the pending documentation This pull request needs an associated documentation update label May 13, 2025
@juliusknorr juliusknorr added this to the Nextcloud 32 milestone May 13, 2025
@nextcloud-bot nextcloud-bot mentioned this pull request Aug 19, 2025
@skjnldsv skjnldsv modified the milestones: Nextcloud 32, Nextcloud 33 Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews pending documentation This pull request needs an associated documentation update performance 🚀

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants