diff options
author | Diva Canto | 2013-07-16 13:01:39 -0700 |
---|---|---|
committer | Diva Canto | 2013-07-16 13:01:39 -0700 |
commit | e0f0b88dece110ca10208a2f826f9e360a9d7826 (patch) | |
tree | 898d5d485db4bc1ebd2a48cead0ae6008628b39b /OpenSim/Region/CoreModules | |
parent | Actually use DoubleQueue in UserManagement/UserManagementModule (diff) | |
download | opensim-SC_OLD-e0f0b88dece110ca10208a2f826f9e360a9d7826.zip opensim-SC_OLD-e0f0b88dece110ca10208a2f826f9e360a9d7826.tar.gz opensim-SC_OLD-e0f0b88dece110ca10208a2f826f9e360a9d7826.tar.bz2 opensim-SC_OLD-e0f0b88dece110ca10208a2f826f9e360a9d7826.tar.xz |
In the pursuit of using less CPU: now trying to avoid blocking queues altogether. Instead, this uses a timer. No sure if it's better or worse, but worth the try.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs | 71 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | 64 |
2 files changed, 120 insertions, 15 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs b/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs index a069317..83be644 100644 --- a/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs +++ b/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs | |||
@@ -48,18 +48,26 @@ namespace OpenSim.Region.CoreModules.Framework | |||
48 | MethodBase.GetCurrentMethod().DeclaringType); | 48 | MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
50 | private readonly List<Scene> m_scenes = new List<Scene>(); | 50 | private readonly List<Scene> m_scenes = new List<Scene>(); |
51 | private System.Timers.Timer m_timer = new System.Timers.Timer(); | ||
51 | 52 | ||
52 | //private OpenSim.Framework.BlockingQueue<GridRegionRequest> m_RequestQueue = new OpenSim.Framework.BlockingQueue<GridRegionRequest>(); | 53 | //private OpenSim.Framework.BlockingQueue<GridRegionRequest> m_RequestQueue = new OpenSim.Framework.BlockingQueue<GridRegionRequest>(); |
53 | private OpenSim.Framework.DoubleQueue<GridRegionRequest> m_RequestQueue = new OpenSim.Framework.DoubleQueue<GridRegionRequest>(); | 54 | // private OpenSim.Framework.DoubleQueue<GridRegionRequest> m_RequestQueue = new OpenSim.Framework.DoubleQueue<GridRegionRequest>(); |
55 | private Queue<GridRegionRequest> m_RequestQueue = new Queue<GridRegionRequest>(); | ||
54 | 56 | ||
55 | public void Initialise(IConfigSource config) | 57 | public void Initialise(IConfigSource config) |
56 | { | 58 | { |
57 | Watchdog.StartThread( | 59 | m_timer = new System.Timers.Timer(); |
58 | ProcessQueue, | 60 | m_timer.AutoReset = false; |
59 | "GridServiceRequestThread", | 61 | m_timer.Interval = 15000; // 15 secs at first |
60 | ThreadPriority.BelowNormal, | 62 | m_timer.Elapsed += ProcessQueue; |
61 | true, | 63 | m_timer.Start(); |
62 | false); | 64 | |
65 | //Watchdog.StartThread( | ||
66 | // ProcessQueue, | ||
67 | // "GridServiceRequestThread", | ||
68 | // ThreadPriority.BelowNormal, | ||
69 | // true, | ||
70 | // false); | ||
63 | } | 71 | } |
64 | 72 | ||
65 | public void AddRegion(Scene scene) | 73 | public void AddRegion(Scene scene) |
@@ -89,6 +97,16 @@ namespace OpenSim.Region.CoreModules.Framework | |||
89 | client.OnRegionHandleRequest += OnRegionHandleRequest; | 97 | client.OnRegionHandleRequest += OnRegionHandleRequest; |
90 | } | 98 | } |
91 | 99 | ||
100 | //void OnMakeRootAgent(ScenePresence obj) | ||
101 | //{ | ||
102 | // lock (m_timer) | ||
103 | // { | ||
104 | // m_timer.Stop(); | ||
105 | // m_timer.Interval = 1000; | ||
106 | // m_timer.Start(); | ||
107 | // } | ||
108 | //} | ||
109 | |||
92 | public void PostInitialise() | 110 | public void PostInitialise() |
93 | { | 111 | { |
94 | } | 112 | } |
@@ -118,7 +136,8 @@ namespace OpenSim.Region.CoreModules.Framework | |||
118 | } | 136 | } |
119 | 137 | ||
120 | GridRegionRequest request = new GridRegionRequest(client, regionID); | 138 | GridRegionRequest request = new GridRegionRequest(client, regionID); |
121 | m_RequestQueue.Enqueue(request); | 139 | lock (m_RequestQueue) |
140 | m_RequestQueue.Enqueue(request); | ||
122 | 141 | ||
123 | } | 142 | } |
124 | 143 | ||
@@ -134,6 +153,41 @@ namespace OpenSim.Region.CoreModules.Framework | |||
134 | return false; | 153 | return false; |
135 | } | 154 | } |
136 | 155 | ||
156 | private bool AreThereRootAgents() | ||
157 | { | ||
158 | foreach (Scene s in m_scenes) | ||
159 | { | ||
160 | if (s.GetRootAgentCount() > 0) | ||
161 | return true; | ||
162 | } | ||
163 | |||
164 | return false; | ||
165 | } | ||
166 | |||
167 | private void ProcessQueue(object sender, System.Timers.ElapsedEventArgs e) | ||
168 | { | ||
169 | while (m_RequestQueue.Count > 0) | ||
170 | { | ||
171 | GridRegionRequest request = null; | ||
172 | lock (m_RequestQueue) | ||
173 | request = m_RequestQueue.Dequeue(); | ||
174 | if (request != null) | ||
175 | { | ||
176 | GridRegion r = m_scenes[0].GridService.GetRegionByUUID(UUID.Zero, request.regionID); | ||
177 | |||
178 | if (r != null && r.RegionHandle != 0) | ||
179 | request.client.SendRegionHandle(request.regionID, r.RegionHandle); | ||
180 | } | ||
181 | } | ||
182 | |||
183 | if (AreThereRootAgents()) | ||
184 | m_timer.Interval = 1000; // 1 sec | ||
185 | else | ||
186 | m_timer.Interval = 10000; // 10 secs | ||
187 | |||
188 | m_timer.Start(); | ||
189 | } | ||
190 | |||
137 | private void ProcessQueue() | 191 | private void ProcessQueue() |
138 | { | 192 | { |
139 | while (true) | 193 | while (true) |
@@ -150,6 +204,7 @@ namespace OpenSim.Region.CoreModules.Framework | |||
150 | } | 204 | } |
151 | } | 205 | } |
152 | } | 206 | } |
207 | |||
153 | } | 208 | } |
154 | 209 | ||
155 | class GridRegionRequest | 210 | class GridRegionRequest |
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 9f5e4ae..61c1e70 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -61,8 +61,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
61 | 61 | ||
62 | // Throttle the name requests | 62 | // Throttle the name requests |
63 | //private OpenSim.Framework.BlockingQueue<NameRequest> m_RequestQueue = new OpenSim.Framework.BlockingQueue<NameRequest>(); | 63 | //private OpenSim.Framework.BlockingQueue<NameRequest> m_RequestQueue = new OpenSim.Framework.BlockingQueue<NameRequest>(); |
64 | private OpenSim.Framework.DoubleQueue<NameRequest> m_RequestQueue = new OpenSim.Framework.DoubleQueue<NameRequest>(); | 64 | //private OpenSim.Framework.DoubleQueue<NameRequest> m_RequestQueue = new OpenSim.Framework.DoubleQueue<NameRequest>(); |
65 | private Queue<NameRequest> m_RequestQueue = new Queue<NameRequest>(); | ||
65 | 66 | ||
67 | private System.Timers.Timer m_timer; | ||
66 | 68 | ||
67 | #region ISharedRegionModule | 69 | #region ISharedRegionModule |
68 | 70 | ||
@@ -599,12 +601,18 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
599 | protected void Init() | 601 | protected void Init() |
600 | { | 602 | { |
601 | RegisterConsoleCmds(); | 603 | RegisterConsoleCmds(); |
602 | Watchdog.StartThread( | 604 | //Watchdog.StartThread( |
603 | ProcessQueue, | 605 | // ProcessQueue, |
604 | "NameRequestThread", | 606 | // "NameRequestThread", |
605 | ThreadPriority.BelowNormal, | 607 | // ThreadPriority.BelowNormal, |
606 | true, | 608 | // true, |
607 | false); | 609 | // false); |
610 | |||
611 | m_timer = new System.Timers.Timer(); | ||
612 | m_timer.AutoReset = false; | ||
613 | m_timer.Interval = 15000; // 15 secs at first | ||
614 | m_timer.Elapsed += ProcessQueue; | ||
615 | m_timer.Start(); | ||
608 | 616 | ||
609 | } | 617 | } |
610 | 618 | ||
@@ -698,6 +706,48 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
698 | } | 706 | } |
699 | } | 707 | } |
700 | 708 | ||
709 | private bool AreThereRootAgents() | ||
710 | { | ||
711 | foreach (Scene s in m_Scenes) | ||
712 | { | ||
713 | if (s.GetRootAgentCount() > 0) | ||
714 | return true; | ||
715 | } | ||
716 | |||
717 | return false; | ||
718 | } | ||
719 | |||
720 | private void ProcessQueue(object sender, System.Timers.ElapsedEventArgs e) | ||
721 | { | ||
722 | while (m_RequestQueue.Count > 0) | ||
723 | { | ||
724 | NameRequest request = null; | ||
725 | lock (m_RequestQueue) | ||
726 | request = m_RequestQueue.Dequeue(); | ||
727 | |||
728 | if (request != null) | ||
729 | { | ||
730 | string[] names; | ||
731 | bool foundRealName = TryGetUserNames(request.uuid, out names); | ||
732 | |||
733 | if (names.Length == 2) | ||
734 | { | ||
735 | if (!foundRealName) | ||
736 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: Sending {0} {1} for {2} to {3} since no bound name found", names[0], names[1], request.uuid, request.client.Name); | ||
737 | |||
738 | request.client.SendNameReply(request.uuid, names[0], names[1]); | ||
739 | } | ||
740 | } | ||
741 | } | ||
742 | |||
743 | if (AreThereRootAgents()) | ||
744 | m_timer.Interval = 1000; // 1 sec | ||
745 | else | ||
746 | m_timer.Interval = 10000; // 10 secs | ||
747 | |||
748 | m_timer.Start(); | ||
749 | |||
750 | } | ||
701 | } | 751 | } |
702 | 752 | ||
703 | class NameRequest | 753 | class NameRequest |