Page MenuHomePhabricator

Attempt to optimize ghost generating code.
ClosedPublic

Authored by lpriestley on Jun 3 2015, 6:06 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Sep 15, 10:30 AM
Unknown Object (File)
Wed, Sep 4, 2:46 PM
Unknown Object (File)
Sun, Sep 1, 7:58 PM
Unknown Object (File)
Sun, Sep 1, 11:22 AM
Unknown Object (File)
Sat, Aug 31, 2:19 PM
Unknown Object (File)
Thu, Aug 29, 8:12 AM
Unknown Object (File)
Thu, Aug 29, 7:49 AM
Unknown Object (File)
Thu, Aug 29, 1:39 AM
Subscribers

Details

Summary

Ref T8394, Attempt to optimize ghost generating code.

Test Plan

Open Upcoming, cancelled only, list view query. Should not hang.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

lpriestley retitled this revision from to Attempt to optimize ghost generating code..
lpriestley updated this object.
lpriestley edited the test plan for this revision. (Show Details)
lpriestley added a reviewer: epriestley.
lpriestley edited edge metadata.

add a failsafe

Taking out safety harness with resultlimit in searchengine

src/applications/calendar/query/PhabricatorCalendarEventQuery.php
112–113

These could be initialized later down now, which might make the code easier to follow.

194

This isn't quite right:

  • We should only enforce the end if we have more than getRawResultLimit() results. If an event recurs 3 times and then has an end date, we'll artificially set $enforced_end to a few weeks from now.
  • We should set the enforced end to getDateFrom() not getDateTo(). We could have 1,000 events ending in an event from 2018-2028. In this case, we'd continue generating events until 2028 the next time through the loop, but can stop in 2018.
  • We should set the enforced end date to the getDateFrom() of the last event in the list, after sorting and slicing. The end date of the last generated event might be too soon (as in the first case above) or too late (in which case we'll do more work than we need to). Even if it's correct, we may have a much better (equally correct and sooner) end date after sorting and slicing.
196

1000 should be $this->getRawResultLimit()

196

Specifically, I'd expect the code to be something like:

if (count($events) > $limit) {
  $events = msort($events, 'getDateFrom');
  $events = array_slice($events, 0, $limit, true);
  $enforced_end = last($events)->getDateFrom();
}

See T8394#118074 for discussion.

237–244

Unused.

src/applications/calendar/query/PhabricatorCalendarEventSearchEngine.php
464–470 ↗(On Diff #31741)

I think we should retain this code, and that it's desirable to show 100 results instead of 1000 in the list view.

Users are rarely interested in 1,000 results, showing 100 is consistent with all other applications, and 1,000 results will always be slower to generate than 100. It shouldn't be a matter of multiple seconds, but the difference between 200ms (feels fast) and 2000ms (feels slow) is pretty big, and the value of those 900 other events is probably almost nothing.

Downloading and rendering 1,000 full events on mobile is likely quite slow, too.

lpriestley added inline comments.
src/applications/calendar/query/PhabricatorCalendarEventQuery.php
112–113

Don't we want it to persist after each recurring event generates its ghosts?

lpriestley marked 3 inline comments as done.

only enforcing end date when event count is greater than limit

using last($events) instead of $events[length-1]

epriestley edited edge metadata.
epriestley added inline comments.
src/applications/calendar/query/PhabricatorCalendarEventQuery.php
112–114

Oh, sorry, I only meant $map and $instance_sequence_pairs.

168

We could potentially do even better here: if $end is set but $enforced_end is sooner, we can use $enforced_end instead (i.e., the sooner of $end and $enforced_end).

189–192

Maybe >= instead of ==? I think we may end up with more results in some cases.

This revision is now accepted and ready to land.Jun 3 2015, 7:48 PM
lpriestley marked 3 inline comments as done.
lpriestley edited edge metadata.

pick soonest of $end and $enforced_end and make sure $enforced_end remembers the soonest of the two.

This revision was automatically updated to reflect the committed changes.