[sldev] Clients newer than 1.18.0.6 unusable on x86_64

Nicholaz Beresford nicholaz at blueflash.cc
Mon Sep 3 11:42:05 PDT 2007


Hi!

I'm currently in the process of debugging memory use as
well (on 32bit Windows).  One area seems to involve
animations. I don't have any solid results yet, but
you can try to apply (reverse) the attached patch,
which seems to be one of the offenders.

Regarding skipping optional updates, there's a parameter
for that in the authenticate() function (llstartup, look
for gSkipOptionalUpdate).

Btw, now that you mention it, I have a user under Vista
with extreme memory growth ... I think he's using 64bit
Vista ... there may be something related.


Nick


Second Life from the inside out:
http://nicholaz-beresford.blogspot.com/


Callum Lerwick wrote:
> Okay, wasted all day yesterday trying to figure this out. 1.18.1.2 and
> 1.18.3.2 are both completely unusable on my wife's x86_64 laptop (512mb
> RAM, Fedora 7, Mobile Radeon 9600, open source r300 DRI). Within minutes
> it rapidly eats up all RAM causing severe swap, making SL, and the
> entire system for that matter, unusable. Am I the only one seeing this?
> 
> I do not see this on i386, neither my laptop (512mb, F7, Intel 830M) or
> a similar i386 box (768mb, F7, Radeon 9800SE, open source r300). It
> handles what has been my primary test (Walk from Furnation Vista to
> Gamma sandboxes, through Alpha) just fine, while only ever using half
> its RAM, never touching swap! The x86_64 machine running 1.18.0.6
> handles it just fine as well.
> 
> Unfortunately, running with massif in an attempt to find where all this
> RAM is being used, seems to kill texture decode dead and also seems to
> make the r300 driver crash so I don't think I'm getting a valid test run
> out of it.
> 
> My Fedora package will stay at 1.18.0.6 until this is fixed. Not that
> its in the repo yet. ;P Which brings up a related question, what's the
> cleanest way to disable the optional update nagbox? I tried to patch it
> out, but the startup code is a nightmare and I quickly gave up as it was
> taking more work than I wanted to put in to it at the time. A while back
> there was some mention of "update channels". I just want the update
> checking disabled entirely, we have our own update system. (RPM,
> yum-updatesd) Though "this client is not compatible with this grid"
> alerts would have to remain.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Click here to unsubscribe or manage your list subscription:
> /index.html
-------------- next part --------------

diff -urN -X srcdiff.ind --strip-trailing-cr linden/indra/llcharacter/llmotion.cpp sl1_18_2_0\linden-orig\indra/llcharacter/llmotion.cpp
--- linden/indra/llcharacter/llmotion.cpp	2007-07-11 15:19:44.000000000 +0200
+++ linden/indra/llcharacter/llmotion.cpp	2007-08-10 10:39:40.000000000 +0200
@@ -126,6 +126,11 @@
 	mDeactivateCallbackUserData = userdata;
 }
 
+BOOL LLMotion::isBlending()
+{
+	return mPose.getWeight() < 1.f;
+}
+
 //-----------------------------------------------------------------------------
 // activate()
 //-----------------------------------------------------------------------------
@@ -142,10 +147,16 @@
 void LLMotion::deactivate()
 {
 	mActive = FALSE;
+	mPose.setWeight(0.f);
 
 	if (mDeactivateCallback) (*mDeactivateCallback)(mDeactivateCallbackUserData);
 
 	onDeactivate();
 }
 
+BOOL LLMotion::canDeprecate()
+{
+	return TRUE;
+}
+
 // End
diff -urN -X srcdiff.ind --strip-trailing-cr linden/indra/llcharacter/llmotion.h sl1_18_2_0\linden-orig\indra/llcharacter/llmotion.h
--- linden/indra/llcharacter/llmotion.h	2007-07-11 15:19:44.000000000 +0200
+++ linden/indra/llcharacter/llmotion.h	2007-08-10 10:39:40.000000000 +0200
@@ -99,13 +99,14 @@
 
 	void setStopped(BOOL stopped) { mStopped = stopped; }
 
+	BOOL isBlending();
+
 	void activate();
 
 	void deactivate();
 
 	BOOL isActive() { return mActive; }
 
-
 public:
 	//-------------------------------------------------------------------------
 	// animation callbacks to be implemented by subclasses
@@ -145,6 +146,11 @@
 	// called when a motion is deactivated
 	virtual void onDeactivate() = 0;
 
+	// can we crossfade this motion with a new instance when restarted?
+	// should ultimately always be TRUE, but lack of emote blending, etc
+	// requires this
+	virtual BOOL canDeprecate();
+
 	// optional callback routine called when animation deactivated.
 	void	setDeactivateCallback( void (*cb)(void *), void* userdata );
 
diff -urN -X srcdiff.ind --strip-trailing-cr linden/indra/llcharacter/llmotioncontroller.cpp sl1_18_2_0\linden-orig\indra/llcharacter/llmotioncontroller.cpp
--- linden/indra/llcharacter/llmotioncontroller.cpp	2007-07-11 15:19:44.000000000 +0200
+++ linden/indra/llcharacter/llmotioncontroller.cpp	2007-08-10 10:39:40.000000000 +0200
@@ -194,34 +194,44 @@
 //-----------------------------------------------------------------------------
 void LLMotionController::addLoadedMotion(LLMotion* motionp)
 {
+	std::set<LLUUID> motions_to_kill;
+
+	// gather all inactive, loaded motions
 	if (mLoadedMotions.size() > MAX_MOTION_INSTANCES)
 	{
 		// too many motions active this frame, kill all blenders
 		mPoseBlender.clearBlenders();
 
-		for (U32 i = 0; i < mLoadedMotions.size(); i++)
+		for (motion_list_t::iterator loaded_motion_it = mLoadedMotions.begin(); 
+			loaded_motion_it != mLoadedMotions.end(); 
+			++loaded_motion_it)
 		{
-			LLMotion* cur_motionp = mLoadedMotions.front();
-			mLoadedMotions.pop_front();
+			LLMotion* cur_motionp = *loaded_motion_it;
 			
 			// motion isn't playing, delete it
 			if (!isMotionActive(cur_motionp))
 			{
-				mCharacter->requestStopMotion(cur_motionp);
-				mAllMotions.erase(cur_motionp->getID());
-				delete cur_motionp;
-				if (mLoadedMotions.size() <= MAX_MOTION_INSTANCES)
-				{
-					break;
-				}
-			}
-			else
-			{
-				// put active motion on back
-				mLoadedMotions.push_back(cur_motionp);
+				motions_to_kill.insert(cur_motionp->getID());
 			}
 		}
 	}
+
+	// clean up all inactive, loaded motions
+	for (std::set<LLUUID>::iterator motion_it = motions_to_kill.begin();
+		motion_it != motions_to_kill.end();
+		++motion_it)
+	{
+		// look up the motion again by ID to get canonical instance
+		// and kill it only if that one is inactive
+		LLUUID motion_id = *motion_it;
+		LLMotion* motionp = findMotion(motion_id);
+		if (motionp && !isMotionActive(motionp))
+		{
+			removeMotion(motion_id);
+		}
+	}
+
+	// add new motion to loaded list
 	mLoadedMotions.push_back(motionp);
 }
 
@@ -280,14 +290,24 @@
 void LLMotionController::removeMotion( const LLUUID& id)
 {
 	LLMotion* motionp = findMotion(id);
+	
+	removeMotionInstance(motionp);
+
+	mAllMotions.erase(id);
+}
+
+// removes instance of a motion from all runtime structures, but does
+// not erase entry by ID, as this could be a duplicate instance
+// use removeMotion(id) to remove all references to a given motion by id.
+void LLMotionController::removeMotionInstance(LLMotion* motionp)
+{
 	if (motionp)
 	{
-		stopMotionLocally(id, TRUE);
+		stopMotionInstance(motionp, TRUE);
 
 		mLoadingMotions.erase(motionp);
 		mLoadedMotions.remove(motionp);
 		mActiveMotions.remove(motionp);
-		mAllMotions.erase(id);
 		delete motionp;
 	}
 }
@@ -348,28 +368,39 @@
 //-----------------------------------------------------------------------------
 BOOL LLMotionController::startMotion(const LLUUID &id, F32 start_offset)
 {
-	// look for motion in our list of created motions
-	LLMotion *motion = createMotion(id);
+	// do we have an instance of this motion for this character?
+	LLMotion *motion = findMotion(id);
+
+	// motion that is stopping will be allowed to stop but
+	// replaced by a new instance of that motion
+	if (motion
+		&& motion->canDeprecate()
+		&& motion->getFadeWeight() > 0.01f // not LOD-ed out
+		&& (motion->isBlending() || motion->getStopTime() != 0.f))
+	{
+		deprecateMotionInstance(motion);
+		// force creation of new instance
+		motion = NULL;
+	}
+
+	// create new motion instance
+	if (!motion)
+	{
+		motion = createMotion(id);
+	}
 
 	if (!motion)
 	{
 		return FALSE;
 	}
-	//if the motion is already active, then we're done
-	else if (isMotionActive(motion)) // motion is playing and...
+	//if the motion is already active and allows deprecation, then let it keep playing
+	else if (motion->canDeprecate() && isMotionActive(motion))
 	{	
-		if (motion->isStopped()) // motion has been stopped
-		{
-			deactivateMotion(motion, false);
-		}
-		else if (mTime < motion->mSendStopTimestamp)	// motion is still active
-		{
-			return TRUE;
-		}
+		return TRUE;
 	}
 
 //	llinfos << "Starting motion " << name << llendl;
-	return activateMotion(motion, mTime - start_offset);
+	return activateMotionInstance(motion, mTime - start_offset);
 }
 
 
@@ -380,6 +411,12 @@
 {
 	// if already inactive, return false
 	LLMotion *motion = findMotion(id);
+
+	return stopMotionInstance(motion, stop_immediate);
+}
+
+BOOL LLMotionController::stopMotionInstance(LLMotion* motion, BOOL stop_immediate)
+{
 	if (!motion)
 	{
 		return FALSE;
@@ -396,7 +433,7 @@
 
 		if (stop_immediate)
 		{
-			deactivateMotion(motion, false);
+			deactivateMotionInstance(motion);
 		}
 		return TRUE;
 	}
@@ -492,7 +529,7 @@
 		{
 			if (motionp->isStopped() && mTime > motionp->getStopTime() + motionp->getEaseOutDuration())
 			{
-				deactivateMotion(motionp, false);
+				deactivateMotionInstance(motionp);
 			}
 			else if (motionp->isStopped() && mTime > motionp->getStopTime())
 			{
@@ -510,7 +547,7 @@
 				if (mLastTime <= motionp->mSendStopTimestamp)
 				{
 					mCharacter->requestStopMotion( motionp );
-					stopMotionLocally(motionp->getID(), FALSE);
+					stopMotionInstance(motionp, FALSE);
 				}
 			}
 			else if (mTime >= motionp->mActivationTimestamp)
@@ -538,7 +575,7 @@
 				if (mLastTime <= motionp->mSendStopTimestamp)
 				{
 					mCharacter->requestStopMotion( motionp );
-					stopMotionLocally(motionp->getID(), FALSE);
+					stopMotionInstance(motionp, FALSE);
 				}
 			}
 
@@ -546,7 +583,8 @@
 			{
 				if (motionp->isStopped() && mTime > motionp->getStopTime() + motionp->getEaseOutDuration())
 				{
-					deactivateMotion(motionp, true);
+					posep->setWeight(0.f);
+					deactivateMotionInstance(motionp);
 				}
 				continue;
 			}
@@ -572,7 +610,8 @@
 			}
 			else
 			{
-				deactivateMotion(motionp, true);
+				posep->setWeight(0.f);
+				deactivateMotionInstance(motionp);
 				continue;
 			}
 		}
@@ -617,7 +656,7 @@
 				if (mLastTime <= motionp->mSendStopTimestamp)
 				{
 					mCharacter->requestStopMotion( motionp );
-					stopMotionLocally(motionp->getID(), FALSE);
+					stopMotionInstance(motionp, FALSE);
 				}
 			}
 
@@ -661,7 +700,7 @@
 				// propagate this to the network
 				// as not all viewers are guaranteed to have access to the same logic
 				mCharacter->requestStopMotion( motionp );
-				stopMotionLocally(motionp->getID(), FALSE);
+				stopMotionInstance(motionp, FALSE);
 			}
 
 		}
@@ -733,7 +772,7 @@
 			// this motion should be playing
 			if (!motionp->isStopped())
 			{
-				activateMotion(motionp, mTime);
+				activateMotionInstance(motionp, mTime);
 			}
 		}
 		else if (status == LLMotion::STATUS_FAILURE)
@@ -741,6 +780,7 @@
 			llinfos << "Motion " << motionp->getID() << " init failed." << llendl;
 			sRegistry.markBad(motionp->getID());
 			mLoadingMotions.erase(curiter);
+
 			mAllMotions.erase(motionp->getID());
 			delete motionp;
 		}
@@ -773,9 +813,9 @@
 
 
 //-----------------------------------------------------------------------------
-// activateMotion()
+// activateMotionInstance()
 //-----------------------------------------------------------------------------
-BOOL LLMotionController::activateMotion(LLMotion *motion, F32 time)
+BOOL LLMotionController::activateMotionInstance(LLMotion *motion, F32 time)
 {
 	if (mLoadingMotions.find(motion) != mLoadingMotions.end())
 	{
@@ -818,23 +858,38 @@
 }
 
 //-----------------------------------------------------------------------------
-// deactivateMotion()
+// deactivateMotionInstance()
 //-----------------------------------------------------------------------------
-BOOL LLMotionController::deactivateMotion(LLMotion *motion, bool remove_weight)
+BOOL LLMotionController::deactivateMotionInstance(LLMotion *motion)
 {
-	if( remove_weight )
+	motion->deactivate();
+
+	motion_set_t::iterator found_it = mDeprecatedMotions.find(motion);
+	if (found_it != mDeprecatedMotions.end())
 	{
-		// immediately remove pose weighting instead of letting it time out
-		LLPose *posep = motion->getPose();
-		posep->setWeight(0.f);
+		// deprecated motions need to be completely excised
+		removeMotionInstance(motion);	
+		mDeprecatedMotions.erase(found_it);
+	}
+	else
+	{
+		// for motions that we are keeping, simply remove from active queue
+		mActiveMotions.remove(motion);
 	}
-	
-	motion->deactivate();
-	mActiveMotions.remove(motion);
 
 	return TRUE;
 }
 
+void LLMotionController::deprecateMotionInstance(LLMotion* motion)
+{
+	mDeprecatedMotions.insert(motion);
+
+	//fade out deprecated motion
+	stopMotionInstance(motion, FALSE);
+	//no longer canonical
+	mAllMotions.erase(motion->getID());
+}
+
 //-----------------------------------------------------------------------------
 // isMotionActive()
 //-----------------------------------------------------------------------------
@@ -857,7 +912,7 @@
 //-----------------------------------------------------------------------------
 LLMotion *LLMotionController::findMotion(const LLUUID& id)
 {
-	return mAllMotions[id];
+	return get_if_there<LLUUID, LLMotion*>(mAllMotions, id, NULL);
 }
 
 //-----------------------------------------------------------------------------
diff -urN -X srcdiff.ind --strip-trailing-cr linden/indra/llcharacter/llmotioncontroller.h sl1_18_2_0\linden-orig\indra/llcharacter/llmotioncontroller.h
--- linden/indra/llcharacter/llmotioncontroller.h	2007-07-11 15:19:44.000000000 +0200
+++ linden/indra/llcharacter/llmotioncontroller.h	2007-08-10 10:39:40.000000000 +0200
@@ -179,16 +179,21 @@
 	LLMotion *findMotion( const LLUUID& id );
 
 protected:
+	// internal operations act on motion instances directly
+	// as there can be duplicate motions per id during blending overlap
 	void deleteAllMotions();
 	void addLoadedMotion(LLMotion *motion);
-	BOOL activateMotion(LLMotion *motion, F32 time);
-	BOOL deactivateMotion(LLMotion *motion, bool remove_weight);
+	BOOL activateMotionInstance(LLMotion *motion, F32 time);
+	BOOL deactivateMotionInstance(LLMotion *motion);
+	void deprecateMotionInstance(LLMotion* motion);
+	BOOL stopMotionInstance(LLMotion *motion, BOOL stop_imemdiate);
+	void removeMotionInstance(LLMotion* motion);
 	void updateRegularMotions();
 	void updateAdditiveMotions();
 	void resetJointSignatures();
 	void updateMotionsByType(LLMotion::LLMotionBlendType motion_type);
-protected:
 
+protected:
 	F32					mTimeFactor;
 	static LLMotionRegistry	sRegistry;
 	LLPoseBlender		mPoseBlender;
@@ -203,11 +208,13 @@
 //	Once an animations is loaded, it will be initialized and put on the mLoadedMotions deque.
 //	Any animation that is currently playing also sits in the mActiveMotions list.
 
-	std::map<LLUUID, LLMotion*>	mAllMotions;
+	typedef std::map<LLUUID, LLMotion*> motion_map_t;
+	motion_map_t	mAllMotions;
 
 	motion_set_t		mLoadingMotions;
 	motion_list_t		mLoadedMotions;
 	motion_list_t		mActiveMotions;
+	motion_set_t		mDeprecatedMotions;
 	
 	LLFrameTimer		mTimer;
 	F32					mTime;
diff -urN -X srcdiff.ind --strip-trailing-cr linden/indra/llcharacter/llpose.cpp sl1_18_2_0\linden-orig\indra/llcharacter/llpose.cpp
--- linden/indra/llcharacter/llpose.cpp	2007-07-11 15:19:44.000000000 +0200
+++ linden/indra/llcharacter/llpose.cpp	2007-08-10 10:39:40.000000000 +0200
@@ -275,9 +275,9 @@
 		joint_state_index < JSB_NUM_JOINT_STATES && mJointStates[joint_state_index] != NULL;
 		joint_state_index++)
 	{
-		U32 current_usage = mJointStates[joint_state_index]->getUsage();
-		F32 current_weight = mJointStates[joint_state_index]->getWeight();
 		LLJointState* jsp = mJointStates[joint_state_index];
+		U32 current_usage = jsp->getUsage();
+		F32 current_weight = jsp->getWeight();
 
 		if (current_weight == 0.f)
 		{
@@ -292,17 +292,14 @@
 
 				// add in pos for this jointstate modulated by weight
 				added_pos += jsp->getPosition() * (new_weight_sum - sum_weights[POS_WEIGHT]);
-				//sum_weights[POS_WEIGHT] = new_weight_sum;
 			}
 
-			// now do scale
 			if(current_usage & LLJointState::SCALE)
 			{
 				F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[SCALE_WEIGHT]);
 
 				// add in scale for this jointstate modulated by weight
 				added_scale += jsp->getScale() * (new_weight_sum - sum_weights[SCALE_WEIGHT]);
-				//sum_weights[SCALE_WEIGHT] = new_weight_sum;
 			}
 
 			if (current_usage & LLJointState::ROT)
@@ -311,7 +308,6 @@
 
 				// add in rotation for this jointstate modulated by weight
 				added_rot = nlerp((new_weight_sum - sum_weights[ROT_WEIGHT]), added_rot, jsp->getRotation()) * added_rot;
-				//sum_weights[ROT_WEIGHT] = new_weight_sum;
 			}
 		}
 		else
@@ -326,13 +322,13 @@
 					F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[POS_WEIGHT]);
 
 					// blend positions from both
-					blended_pos = lerp(mJointStates[joint_state_index]->getPosition(), blended_pos, sum_weights[POS_WEIGHT] / new_weight_sum);
+					blended_pos = lerp(jsp->getPosition(), blended_pos, sum_weights[POS_WEIGHT] / new_weight_sum);
 					sum_weights[POS_WEIGHT] = new_weight_sum;
 				} 
 				else
 				{
 					// copy position from current
-					blended_pos = mJointStates[joint_state_index]->getPosition();
+					blended_pos = jsp->getPosition();
 					sum_weights[POS_WEIGHT] = current_weight;
 				}
 			}
@@ -345,13 +341,13 @@
 					F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[SCALE_WEIGHT]);
 
 					// blend scales from both
-					blended_scale = lerp(mJointStates[joint_state_index]->getScale(), blended_scale, sum_weights[SCALE_WEIGHT] / new_weight_sum);
+					blended_scale = lerp(jsp->getScale(), blended_scale, sum_weights[SCALE_WEIGHT] / new_weight_sum);
 					sum_weights[SCALE_WEIGHT] = new_weight_sum;
 				} 
 				else
 				{
 					// copy scale from current
-					blended_scale = mJointStates[joint_state_index]->getScale();
+					blended_scale = jsp->getScale();
 					sum_weights[SCALE_WEIGHT] = current_weight;
 				}
 			}
@@ -364,13 +360,13 @@
 					F32 new_weight_sum = llmin(1.f, current_weight + sum_weights[ROT_WEIGHT]);
 
 					// blend rotations from both
-					blended_rot = nlerp(sum_weights[ROT_WEIGHT] / new_weight_sum, mJointStates[joint_state_index]->getRotation(), blended_rot);
+					blended_rot = nlerp(sum_weights[ROT_WEIGHT] / new_weight_sum, jsp->getRotation(), blended_rot);
 					sum_weights[ROT_WEIGHT] = new_weight_sum;
 				} 
 				else
 				{
 					// copy rotation from current
-					blended_rot = mJointStates[joint_state_index]->getRotation();
+					blended_rot = jsp->getRotation();
 					sum_weights[ROT_WEIGHT] = current_weight;
 				}
 			}
diff -urN -X srcdiff.ind --strip-trailing-cr linden/indra/llcharacter/llpose.h sl1_18_2_0\linden-orig\indra/llcharacter/llpose.h
--- linden/indra/llcharacter/llpose.h	2007-07-11 15:19:44.000000000 +0200
+++ linden/indra/llcharacter/llpose.h	2007-08-10 10:39:40.000000000 +0200
@@ -81,7 +81,7 @@
 	S32 getNumJointStates() const;
 };
 
-const S32 JSB_NUM_JOINT_STATES = 4;
+const S32 JSB_NUM_JOINT_STATES = 6;
 
 class LLJointStateBlender
 {


More information about the SLDev mailing list