Homec4science

Improve LiskDAO::__call() performance

Authored by epriestley <git@epriestley.com> on Dec 29 2011, 23:23.

Description

Improve LiskDAO::__call() performance

Summary:
This is kind of expensive and can be significant on, e.g., the
Maniphest task list view. Do a little more caching and some clever nonsense to
improve performance.

Test Plan:
Local cost on Maniphest "all tasks" view for this method dropped from

82,856us to 24,607us## on 9,061 calls.

I wrote some unit test / microbenchmark things:

public function testGetIDCost() {
  $u = new PhabricatorUser();
  $n = 100000;
  while ($n--) {
    $u->getID();
  }
  $this->assertEqual(1, 1);
}

public function testGetCost() {
  $u = new PhabricatorUser();
  $n = 100000;
  while ($n--) {
    $u->getUsername();
  }
  $this->assertEqual(1, 1);
}

public function testSetCost() {
  $u = new PhabricatorUser();
  $n = 100000;
  while ($n--) {
    $u->setID(1);
  }
  $this->assertEqual(1, 1);
}

Before:

PASS  598ms   testSetCost
PASS  584ms   testGetCost
PASS  272ms   testGetIDCost

After:

PASS  170ms   testSetCost
PASS  207ms   testGetCost
PASS   29ms   testGetIDCost

Also, ran unit tests.

Reviewers: nh, btrahan, jungejason

Reviewed By: nh

CC: aran, epriestley, nh

Differential Revision: https://secure.phabricator.com/D1291

Details

Committed
epriestley <git@epriestley.com>Jan 4 2012, 07:03
Pushed
aubortJan 31 2017, 17:16
Parents
rPH8f289e6687cc: Add documentaion about literal block
Branches
Unknown
Tags
Unknown

Event Timeline

epriestley <git@epriestley.com> committed rPH7831b9242760: Improve LiskDAO::__call() performance (authored by epriestley <git@epriestley.com>).Jan 4 2012, 07:03