#7824 Cache neighborhood record

v1.2.1
closed
General
2015-08-20
2015-02-03
No

Every single request hits RootController.__init__ and does a neighborhood lookup. Neighborhoods don't change very often so this could be cached in-memory for a short time. I think the duration should be configurable and default to 0 (particularly so development is easy). Based on some performance monitoring I did, this may save up to 15% of time spent in a simple request (smaller relative % on more complex pages)

Discussion

  • Igor Bondarenko - 2015-02-04
    • labels: performance, sf-current --> performance, sf-current, 42cc
    • status: open --> in-progress
    • assigned_to: Igor Bondarenko
     
  • Igor Bondarenko - 2015-02-05
    • status: in-progress --> review
     
  • Igor Bondarenko - 2015-02-05

    Closed #721. ib/7824

    Some timings of neighborhood lookup. First hit - after server restart.

    Before cache:

    08:35:55,716 INFO  [allura.controllers.root] TIME: 14.0540599823 ms
    08:35:57,142 INFO  [allura.controllers.root] TIME: 1.22499465942 ms
    08:35:57,209 INFO  [allura.controllers.root] TIME: 0.859022140503 ms
    

    After cache:

    08:47:57,925 INFO  [allura.controllers.root] TIME: 14.1131877899 ms
    08:47:58,719 INFO  [allura.controllers.root] TIME: 0.0700950622559 ms
    08:47:59,622 INFO  [allura.controllers.root] TIME: 0.0560283660889 ms
    

    QA:

    • add neighborhood.cache.duration = 60 to config
    • go to /adobe/admin/, make sure you see 'Adobe' at the top of the page
    • mongo pyforge
    • db.neighborhood.update({'url_prefix': '/adobe/'}, {'$set': {'name': 'Adobe 1'}})
    • refresh page, make sure you still see cached neighborhood name
    • wait a minure, refresh page again, make sure neighborhood name is updated
    • make sure other neighborhoods work and 404 page is shown when appropriate
     
  • Dave Brondsema

    Dave Brondsema - 2015-02-06
    • Reviewer: Dave Brondsema
     
  • Dave Brondsema

    Dave Brondsema - 2015-02-06

    +1 except for a minor issue: when I changed the name and it was still cached /p/test/blog/ would redirect to /p/test I added a commit to ib/7824 with a fix and full explanation. If you're good with that, go ahead and merge & close. The caching looks good to me.

     
  • Igor Bondarenko - 2015-02-09
    • status: review --> closed
     
  • Dave Brondsema

    Dave Brondsema - 2015-02-09
    • labels: performance, sf-current, 42cc --> performance, 42cc, sf-1
     
  • Igor Bondarenko - 2015-02-18
    • Milestone: unreleased --> asf_release_1.2.1
     

Log in to post a comment.