Bug 1010006 - PERF: Fetch of districts is very slow
PERF: Fetch of districts is very slow
Status: CLOSED CURRENTRELEASE
Product: OpenShift Online
Classification: Red Hat
Component: Pod (Show other bugs)
2.x
Unspecified Unspecified
unspecified Severity urgent
: ---
: ---
Assigned To: Dan McPherson
libra bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-19 12:53 EDT by Dan McPherson
Modified: 2015-05-14 20:20 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-10-17 09:29:44 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Dan McPherson 2013-09-19 12:53:41 EDT
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 14:53:44 EDT
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 17:20:52 EDT
The fix here is not to include available_uids when finding a node during app create.
Comment 3 Dan McPherson 2013-09-19 17:21:28 EDT
https://github.com/openshift/origin-server/pull/3667
Comment 4 Jianwei Hou 2013-09-22 01:21:01 EDT
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.