Bug 1010006 - PERF: Fetch of districts is very slow
Summary: PERF: Fetch of districts is very slow
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OpenShift Online
Classification: Red Hat
Component: Pod
Version: 2.x
Hardware: Unspecified
OS: Unspecified
unspecified
urgent
Target Milestone: ---
: ---
Assignee: Dan McPherson
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-09-19 16:53 UTC by Dan McPherson
Modified: 2015-05-15 00:20 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-10-17 13:29:44 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Dan McPherson 2013-09-19 16:53:41 UTC
Description of problem:

The initialize method for district is calling save!  So if we query a list of 50 districts we do 50 saves.  This is taking ~300ms in prod for every app create.


Version-Release number of selected component (if applicable):


How reproducible:
100%


Steps to Reproduce:
1. Do anything that gets a district
2.
3.

Actual results:
It saves the district


Expected results:
It shouldn't save the district


Additional info:

Comment 1 Dan McPherson 2013-09-19 18:53:44 UTC
Correction:  It looks like new isn't being called by mongoid on subsequent fetches.  Looks like it might just be the amount of data being returned that's the issue.

Comment 2 Dan McPherson 2013-09-19 21:20:52 UTC
The fix here is not to include available_uids when finding a node during app create.

Comment 3 Dan McPherson 2013-09-19 21:21:28 UTC
https://github.com/openshift/origin-server/pull/3667

Comment 4 Jianwei Hou 2013-09-22 05:21:01 UTC
Verified on devenv_3810

1. Create 51 disctricst with oo-admin-ctl-district
libra_rs:PRIMARY> db.districts.count()
51

2. Connect to datastore, verify the unique indexes have been enabled on the district collection
libra_rs:PRIMARY> db.districts.getIndexes()
[
	{
		"v" : 1,
		"key" : {
			"_id" : 1
		},
		"ns" : "openshift_broker_dev.districts",
		"name" : "_id_"
	},
	{
		"v" : 1,
		"key" : {
			"name" : 1
		},
		"unique" : true,
		"ns" : "openshift_broker_dev.districts",
		"name" : "name_1"
	},
	{
		"v" : 1,
		"key" : {
			"uuid" : 1
		},
		"unique" : true,
		"ns" : "openshift_broker_dev.districts",
		"name" : "uuid_1"
	},
	{
		"v" : 1,
		"key" : {
			"gear_size" : 1
		},
		"ns" : "openshift_broker_dev.districts",
		"name" : "gear_size_1"
	}
]
3. Query districts
irb(main):007:0> require '/var/www/openshift/broker/config/environment'
irb(main):007:0> require '/opt/rh/ruby193/root/usr/share/gems/gems/openshift-origin-controller-1.15.0/app/models/district.rb'
irb(main):052:0> a = Time.now;District.find_all();b = Time.now - a
=> 0.671984381
irb(main):053:0> a = Time.now;District.find_all(nil,false);b = Time.now - a
=> 0.005056106

Takes 5ms when uuids are not included in the query criterion。


Note You need to log in before you can comment on or make changes to this bug.