Skip to content

Depth infinity: Make recursive PROPFIND calls cheaper #14531

Closed

Description

@danimo

Testcase

curl -XPROPFIND https://user:pwd@server/owncloud/remote.php/webdav -H "Depth:infinity"

Actual results

On a well-equipped x86_64 machine it takes 7:20 minutes under heavy server load to list 5279 items (dirs/files).

Expected results

This should actually be fairly cheap, since all required information is available from the DB. The suspicion is that we could attain some serious speedup by investigating code paths and DB queries and optimizing them.

Motivation

Cheap recursive PROPFINDs would allow the client to move away from doing directory-by-directory discovery, which in turn would significantly speed up syncs, especially all sync runs until completing initial sync.

Activity

  1. added this to the milestone on Feb 26, 2015
  2. DeepDiver1975 commented on Feb 26, 2015

    @DeepDiver1975
    Contributor

    @icewind1991 just another case for profiling webdav - please have a look - THX

  3. guruz commented on Feb 26, 2015

    @guruz
    Contributor

    Note that 1.8 has recursive PROPFIND disabled, this issue only affects 1.7.x

    Sabre also creates the XML Reply in memory, maybe this could be streamed to the client instead..

  4. DeepDiver1975 commented on Feb 26, 2015

    @DeepDiver1975
    Contributor

    Sabre also creates the XML Reply in memory, maybe this could be streamed to the client instead..

    @evert ?? THX

  5. evert commented on Feb 26, 2015

    @evert

    Congrats on finding the exact reason I didn't want this feature in the first place, and it's now disabled by default ;). It basically enabled a DDOS attack fairly easily. Do a few of these PROPFINDs in parallel, and the entire server grinds to a halt.

    However, streaming xml is coming. This requires two things:

    1 -> Completion and integration on the 'xml-rewrite2' branch. This is a project I've been on and off working on for about 2 years now and actually getting pretty close to integration.

    Pull request here: https://github.com/fruux/sabre-dav/pull/602

    This spawned a separate project sabre/xml which I'm also working on getting to a full release:

    http://sabre.io/xml/

    1. Allowing users to return iterators (and generators) wherever arrays are used.

    Most of the time when creating the response for this is not just spent writing xml, the most important thing is that the entire WebDAV tree needs to be traversed on the server. Most of the work is in fetching every node, checking access control, etc...

    To properly enable streaming support, we need to be able to get the results as they come in and create the xml on the fly.

    Doing this is scheduled after a next major sabre/dav release, as PHP 5.5 is required for full generator support, and I don't want to do a half-baked version of this with Iterators first.

    However, none of this will really affect the total time spent (7:20) as the exact same processing is still happening. The difference is that there's lower memory usage and the first byte returns a lot quicker.

    To reduce the total time spent, you should still do some proper profiling as @DeepDiver1975 said.

  6. PVince81 commented on Feb 26, 2015

    @PVince81
    Contributor

    Why is recursive PROPFIND needed in the first place ?
    Is this mostly for the initial sync ?

    Let me think:
    Once everything is synced, a PROPFIND on the root should be enough to compare etags. If the etag is different, then need to do a PROPFIND to get the folder content and see which etag changed there.

  7. evert commented on Feb 26, 2015

    @evert

    Only if you talk to broken servers. An ETag shouldn't say anything about the contents of a collection, so you shouldn't rely on this behavior if you are trying to build a standard client.

    Instead, you can use the ctag (or better yet) use the sync-collection.

  8. PVince81 commented on Feb 26, 2015

    @PVince81
    Contributor

    Can we use our existing etags as ctags ? 😉 (whatever that is, need to look it up)

  9. PVince81 commented on Feb 26, 2015

    @PVince81
    Contributor

    Here was a result from blackfire.io I did when testing with Sabre 2.1, it was a PROPFIND with depth 1 on a folder with 69 entries: https://blackfire.io/profiles/6f6c0033-da1e-43d0-b886-b5eeeb62286c/graph

  10. evert commented on Feb 26, 2015

    @evert

    Ctag is also non-standard, but it's well defined:

    http://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk/doc/Extensions/caldav-ctag.txt

    The problem with using the ETag is that it does have a specific definition, and that definition is incompatible with how you are using the etag.

    So while this ctag was meant for calendars, it makes sense for any collection.

    However, sync-tokens are even better. Instead of doing a full PROPFIND every time, you literally ask for all changes since the last sync-token you received which can make this incredibly fast.

  11. PVince81 commented on Feb 26, 2015

    @PVince81
    Contributor
       Description:  The CS:getctag property allows clients to quickly
          determine if the contents of a calendar or scheduling Inbox or
          Outbox collection have changed since the last time a
          "synchronization" operation was done.  The CS:getctag property
          value MUST change each time the contents of the calendar or
          scheduling Inbox or Outbox collection change, and each change MUST
          result in a value that is different from any other used with that
          collection URI.
    

    That sounds like our etags. When the collection content changes (or any subcollection), the etag will change.

    So would it just be a matter of renaming "getetag" to "getctag" ?

    Last changes since the last sync means the server needs to remember the states that it returned for every sync client so it can diff it, which cannot be done with the current architecture/data model. It was suggested by @icewind1991 here: #4936 (speed up by keeping etag history)

  12. evert commented on Feb 26, 2015

    @evert

    Implementing this:

    http://tools.ietf.org/html/rfc6578

    Will basically solve any performance problems you have today of this kind. It will greatly reduce memory usage and cpu usage on both server and client. You literally just get a list of deletions and additions back.

  13. evert commented on Feb 26, 2015

    @evert

    So would it just be a matter of renaming "getetag" to "getctag" ?

    It's also in a different namespace.

    Last changes since the last sync means the server needs to remember the states that it returned for every sync client so it can diff it, which cannot be done with the current architecture/data model. It was suggested by @icewind1991 here: #4936 (speed up by keeping etag history)

    That sounds very similar indeed. What you need from a database perspective:

    1. A primary key (this becomes your sync token, can just be an incremental id)
    2. The path to the file that was changed
    3. The type of operation (modify/create/delete)

    It's pretty lightweight

  14. PVince81 commented on Feb 26, 2015

    @PVince81
    Contributor

    So does it mean that for every file change (rename, delete, upload, download, even outside of WebDAV) need to create a new entry there ? Or should these be grouped ?

    "the path of the file that was changed": the path can change if the file was moved. So possibly need more info about moved stuff.

  15. 25 remaining items

  16. michaelstingl commented on Mar 15, 2017

    @michaelstingl

    … adding @mrow4a to the discussion about performance…

  17. mrow4a commented on Mar 15, 2017

    @mrow4a
    Contributor

    Working on it, and see no ending :>

    #27372
    #27339
    #27373
    #27284

  18. guruz commented on Mar 23, 2017

    @guruz
    Contributor

    Some data points:
    A infinity PROPFIND XML reply taking uncompressed 12 MB (around 2900 directories, around 20.000 files)
    Downloads currently in 25 sec using curl.
    I didn't check the server memory usage.

    (no memory / XML streaming operations yet).

  19. changed the title [-]Make recursive PROPFIND calls cheaper[/-] [+]Depth infinity: Make recursive PROPFIND calls cheaper[/+] on Mar 24, 2017
  20. PVince81 commented on Mar 30, 2017

    @PVince81
    Contributor
  21. guruz commented on Apr 4, 2017

    @guruz
    Contributor

    When implementing this, please also try to gzip the response stream.

    Right now in our recommended web server configs we disable gzip because some web servers mess with ETags then. But for the text-based PROPFIND it still makes sense.

  22. ogoffart commented on Apr 5, 2017

    @ogoffart

    Right now in our recommended web server configs we disable gzip because some web servers mess with ETags then

    We have been using OC-ETAG snice mirall 1.7.0, so i think we can ignore this issue now. (are we still supporting such clients)

    But I wonder about the resuming when downloading files.

  23. hodyroff commented on Apr 5, 2017

    @hodyroff

    Support as in Support Contract and active fixing = latest version only
    Support as in should work and if not we consider it a bug = 2.0 with 10.0; 1.8 with 9.1 IMHO

  24. PVince81 commented on Jul 10, 2017

    @PVince81
    Contributor

    bug with Infinity: #28341

  25. added this to the backlog milestone on Nov 5, 2018
  26. michaelstingl commented on Jul 9, 2021

    @michaelstingl

    Related: #38583

  27. stale commented on Sep 20, 2021

    @stale

    This issue has been automatically closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions