Ways to decrease CPU usage on G2.1?

summetj

Joined: 2005-12-29
Posts: 21
Posted: Fri, 2006-04-14 15:50

I have a relatively small Gallery (150 users, 1800 images) with relatively small amounts of traffic (~42GB transfer a month, serving 28K pages a day, 2,500 unique visitors a day, etc).

However, even that small amount of traffic is generating a large CPU load (as my hosting provider is quick to point out to me) of 80-200 CPU minutes a day. (I'm supposed to be using under 60 CPU minutes.)

I upgraded to Gallery 2.1, turned on performance caching (Full accelleration for users who are not logged in, the majority, and partial acceleration for registered users), but haven't seen any real improvement in CPU minute usage vs Gallery 2.0.

Are their any other tips/tricks I can use to reduce the CPU usage?
Any improvements to CVS version of gallery that might help significantly?

Thanks,
Jay

 
joe7rocks
joe7rocks's picture

Joined: 2004-10-07
Posts: 560
Posted: Fri, 2006-04-14 17:39

uhm.. could you enable profiling in config.php for ~10mins and then show us which queries take the most time?

 
summetj

Joined: 2005-12-29
Posts: 21
Posted: Fri, 2006-04-14 19:50

Ok, I found and changed the config.php option to: $gallery->setProfile(true);

Where do I find the profile log or output?

 
joe7rocks
joe7rocks's picture

Joined: 2004-10-07
Posts: 560
Posted: Fri, 2006-04-14 20:55

at the bottom of your every page! :O
but You might need to disable caching to get this

 
summetj

Joined: 2005-12-29
Posts: 21
Posted: Fri, 2006-04-14 22:44

Ok, got it. Cut & paste output not terribly great, so I've also attached the HTML file.

Debug Output
Suspicious SQL
The following SQL have high average execution times
Avg Time Count SQL Max Min
0.033109 2 SELECT g2_Item.g_id, g2_User.g_fullName, g2_User.g_userName, g2_Entity.g_modificationTimestamp, g2_Item.g_description, g2_Item.g_keywords, g2_Item.g_summary, g2_Item.g_title FROM g2_Item, g2_AccessSubscriberMap, g2_Entity, g2_User WHERE (g2_Item.g_description LIKE ? OR g2_Item.g_keywords LIKE ? OR g2_Item.g_summary LIKE ? OR g2_Item.g_title LIKE ?) AND g2_Item.g_id = g2_AccessSubscriberMap.g_itemId AND g2_Item.g_id = g2_Entity.g_id AND g2_User.g_id = g2_Item.g_ownerId AND g2_AccessSubscriberMap.g_accessListId IN (?,?,?) ORDER BY g2_Entity.g_modificationTimestamp DESC, g2_Item.g_id DESC LIMIT 3 0.040612 0.025606
0.021191 2 SELECT COUNT(g2_Item.g_id) FROM g2_Item, g2_AccessSubscriberMap WHERE (g2_Item.g_description LIKE ? OR g2_Item.g_keywords LIKE ? OR g2_Item.g_summary LIKE ? OR g2_Item.g_title LIKE ?) AND g2_Item.g_id = g2_AccessSubscriberMap.g_itemId AND g2_AccessSubscriberMap.g_accessListId IN (?,?,?) 0.027521 0.014861
0.016497 1 INSERT INTO g2_CacheMap (g_key, g_value, g_userId, g_itemId, g_type, g_timestamp) VALUES (?,?,?,?,?,?) 0.016497 0.016497
0.014063 19 SELECT g2_CacheMap.g_value FROM g2_CacheMap WHERE g2_CacheMap.g_key = ? AND g2_CacheMap.g_type = ? AND g2_CacheMap.g_userId = ? AND g2_CacheMap.g_timestamp > ? 0.040192 0.001472
0.009701 3 SELECT g2_ChildEntity.g_parentId, COUNT(g2_ChildEntity.g_id) FROM g2_ChildEntity, g2_AccessSubscriberMap WHERE g2_ChildEntity.g_parentId IN (?,?,?,?,?,?,?,?,?,?) AND g2_AccessSubscriberMap.g_itemId = g2_ChildEntity.g_id AND g2_AccessSubscriberMap.g_accessListId IN (?,?,?) GROUP BY g2_ChildEntity.g_parentId 0.013987 0.006937
0.008988 6 SELECT g2_ImageBlockCacheMap.g_itemId FROM g2_ImageBlockCacheMap LEFT JOIN g2_ImageBlockDisabledMap ON g2_ImageBlockCacheMap.g_itemId=g2_ImageBlockDisabledMap.g_itemId WHERE g2_ImageBlockCacheMap.g_userId = ? AND g2_ImageBlockCacheMap.g_itemType = ? AND g2_ImageBlockDisabledMap.g_itemId IS NULL ORDER BY RAND() LIMIT 1 0.011452 0.005764
0.008771 3 SELECT iam0.g_itemId, COUNT(iam1.g_itemId) FROM g2_ItemAttributesMap AS iam0, g2_ItemAttributesMap AS iam1, g2_AccessSubscriberMap WHERE iam0.g_itemId IN (?) AND iam1.g_parentSequence LIKE CONCAT(iam0.g_parentSequence, iam0.g_itemId, '/%') AND iam1.g_itemId = g2_AccessSubscriberMap.g_itemId AND g2_AccessSubscriberMap.g_accessListId IN (?,?,?) GROUP BY iam0.g_itemId 0.009628 0.007352
0.008297 2 SELECT COUNT(g2_ChildEntity.g_id) FROM g2_ChildEntity, g2_Comment, g2_AccessSubscriberMap WHERE g2_ChildEntity.g_id = g2_Comment.g_id AND g2_ChildEntity.g_parentId = g2_AccessSubscriberMap.g_itemId AND g2_AccessSubscriberMap.g_accessListId IN (?) AND (g2_Comment.g_subject LIKE ? OR g2_Comment.g_comment LIKE ?) 0.011690 0.004903
0.007135 3 UPDATE g2_CacheMap SET g_value=?, g_timestamp=? WHERE g_key=? AND g_userId=? AND g_itemId=? AND g_type=? 0.008745 0.005865
0.007085 3 SELECT g2_Derivative.g_id, g2_ChildEntity.g_parentId FROM g2_Derivative, g2_ChildEntity WHERE g2_Derivative.g_id = g2_ChildEntity.g_id AND g2_ChildEntity.g_parentId IN (?,?,?,?,?,?,?,?,?,?) AND g2_Derivative.g_derivativeType IN (?) 0.009508 0.005595
Expensive SQL
Tuning the following SQL could reduce the server load substantially
Load Count SQL Max Min
0.267202 19 SELECT g2_CacheMap.g_value FROM g2_CacheMap WHERE g2_CacheMap.g_key = ? AND g2_CacheMap.g_type = ? AND g2_CacheMap.g_userId = ? AND g2_CacheMap.g_timestamp > ? 0.040192 0.001472
0.229300 75 SET NAMES "utf8" 0.011609 0.000607
0.173235 50 SELECT g2_G1MigrateMap.g_itemId FROM g2_G1MigrateMap WHERE g2_G1MigrateMap.g_g1album=? AND g2_G1MigrateMap.g_g1item=? 0.015824 0.000540
0.087510 29 SELECT DISTINCT g2_AccessMap.g_accessListId FROM g2_AccessMap WHERE g2_AccessMap.g_userOrGroupId IN (?,?) AND g2_AccessMap.g_permission & ? = ? 0.005690 0.000794
0.068600 24 SELECT g2_Group.g_id, g2_Group.g_groupName FROM g2_UserGroupMap, g2_Group WHERE g2_Group.g_id = g2_UserGroupMap.g_groupId AND g2_UserGroupMap.g_userId = ? ORDER BY g2_Group.g_groupName LIMIT 18446744073709551615 0.008022 0.000934
0.066218 2 SELECT g2_Item.g_id, g2_User.g_fullName, g2_User.g_userName, g2_Entity.g_modificationTimestamp, g2_Item.g_description, g2_Item.g_keywords, g2_Item.g_summary, g2_Item.g_title FROM g2_Item, g2_AccessSubscriberMap, g2_Entity, g2_User WHERE (g2_Item.g_description LIKE ? OR g2_Item.g_keywords LIKE ? OR g2_Item.g_summary LIKE ? OR g2_Item.g_title LIKE ?) AND g2_Item.g_id = g2_AccessSubscriberMap.g_itemId AND g2_Item.g_id = g2_Entity.g_id AND g2_User.g_id = g2_Item.g_ownerId AND g2_AccessSubscriberMap.g_accessListId IN (?,?,?) ORDER BY g2_Entity.g_modificationTimestamp DESC, g2_Item.g_id DESC LIMIT 3 0.040612 0.025606
0.061450 21 SELECT g2_AccessSubscriberMap.g_itemId, BIT_OR(g2_AccessMap.g_permission) FROM g2_AccessMap, g2_AccessSubscriberMap WHERE g2_AccessSubscriberMap.g_itemId IN (?) AND g2_AccessSubscriberMap.g_accessListId = g2_AccessMap.g_accessListId AND g2_AccessMap.g_userOrGroupId IN (?,?) GROUP BY g2_AccessSubscriberMap.g_itemId 0.016627 0.000769
0.060435 24 SELECT g2_PermissionSetMap.g_module, g2_PermissionSetMap.g_permission, g2_PermissionSetMap.g_description, g2_PermissionSetMap.g_bits, g2_PermissionSetMap.g_flags FROM g2_PermissionSetMap 0.005022 0.001127
0.053925 6 SELECT g2_ImageBlockCacheMap.g_itemId FROM g2_ImageBlockCacheMap LEFT JOIN g2_ImageBlockDisabledMap ON g2_ImageBlockCacheMap.g_itemId=g2_ImageBlockDisabledMap.g_itemId WHERE g2_ImageBlockCacheMap.g_userId = ? AND g2_ImageBlockCacheMap.g_itemType = ? AND g2_ImageBlockDisabledMap.g_itemId IS NULL ORDER BY RAND() LIMIT 1 0.011452 0.005764
0.043907 17 SELECT g2_FileSystemEntity.g_id FROM g2_FileSystemEntity, g2_ChildEntity WHERE g2_ChildEntity.g_parentId = ? AND g2_ChildEntity.g_id = g2_FileSystemEntity.g_id AND g2_FileSystemEntity.g_pathComponent = ?

 
joe7rocks
joe7rocks's picture

Joined: 2004-10-07
Posts: 560
Posted: Fri, 2006-04-14 23:05

well.. i don't see anything really bad here.
You might should set profiling on for a longer time and/or make sure you have a lot of access to your gallery while it's on (uploads/visits with more userId etc) to get a real picture on what's going on there.
can't really suggest anything with this result :|
(bah, i shouldn't start with the codeoutput next time.. and only realize the attachment when i read through;)