Optimizing your Application’s CPU & Memory Performance
Brian Madden will explore the CPU and DLL optimization capabilities offered in Presentation Server and their ability to improve user density and provide an improved and consistent user experience. With the capabilities of CPU and DLL optimizations, your servers will be able to more efficiently manage memory and fairly distribute CPU loads. (Running time: 42:13 minutes)
Tags: technical video
Views: 3,019
Rating: 5
Transcript : Hello. My name is Brian Madden. I am an independent consultant focusing on Citrix and various application delivery technologies. In this video, I’m going to talk about two features of Citrix Presentation Server 4.5. The features are Citrix’s CPU optimization management and Citrix’s memory optimization management. The idea with this video is that if you are not familiar with these features, I’ll discuss how they work, how you configure them, and how they can be used within your environment to get better performance on your existing servers. So, first, a couple of introductory kind of things. Both CPU and memory optimization were introduced in Presentation Server version 4. Now, in Presentation Server 4.5, they’re basically the same. They function the same way. There’s a few small differences that we’ll mention throughout this video, but they’re basically the same in 4.5 as they are in Presentation Server 4. CPU and memory optimization management, I think, are two features that are really underappreciated, I think, by a lot of people in the industry. And these are some good stuff. So this is what I want to look at and kind of understand how they work within this video. So let’s begin by looking at the CPU optimization feature of Presentation Server. Before we go into those very specifics, I want to look at CPU optimization in general. Forget about Citrix for a moment and server-based computing. I just want to look at CPU, and there’s a couple things I want to say about this. And the first thing I’ll say is understanding whether your Presentation Server has a CPU problem, it’s not as simple as just looking at Task Manager. Let me give you an example here. If I fire up Task Manager, click on the Performance tab, probably most people watching this video will simply look at this green line of CPU utilization and think, okay, well, on this particular server, my utilization is 20...15%, something like that. This is okay. It’s not too busy. This server is okay. Well the point I want to make is that I, personally, don’t think you can just simply look at this green line to see if you have a CPU bottleneck on your server. Let me give you an example of this. If I run an application…I’m just going to run Calculator. Okay. I put my calculator into scientific mode. And let me just type a kind of random number here and click the factorial button. Now as soon as I click this factorial button, what happens? You see my CPU has spiked at 100% utilization. So, this is funny actually. Even Calculator’s telling me, hey, are you sure you want to do this? It’s kind of crazy. So look right now. My CPU is spiked at 100%. So a lot of people, I think, will see this and become nervous, and think, wow, my server’s so busy I…it’s very bad for performance, and I have to change it, and I have to do something about that. But look at this. Watch as I click through here. Click on the PowerPoint. Click on this Access Management Console. Maybe click around a little bit. Click back here. Click back in Calculator. Click on Start Menu. You see my system is very responsive. So even though my CPU is at 100% utilization, I don’t actually have a bad performance problem in this case. So I use this as an example to kind of illustrate that 100% CPU is not necessarily bad. Now, while this is happening, I just heard my fans kick on, on my laptop here, so I’m going to ahead and stop this. And this says operation canceled. Go ahead and close this Calculator. And you see our CPU goes back down. My point, though, is when you’re trying to figure out whether you have a CPU bottleneck within your environment, it’s not quite as easy as looking at what your CPU utilization is. You really need to think more about the performance that the users experience. And, in this case, since my user performance was not negatively impacted, I think that’s okay. I think it’s really no problem. In fact, I’ll take that one step farther and say in some cases, you could even make the argument that higher CPU utilization is better. Because, if you think about it, this green line here, it’s not really showing how busy the CPU is. Because, if the CPU is executing at 3 gigahertz, that’s 3 billion ticks of the clock per second. That happens regardless of whether the CPU has work to do or not. Basically, this green line here is just showing the ratio of how much actual work is this CPU doing, how much useful work is it doing vs. how much time is it executing an idle thread where it’s not doing anything. So the point is, the CPU is doing the same amount of work always. It’s just how much work is it doing that you want vs. not doing work. And I would argue that the higher the CPU utilization is, that means that our system is running more efficiently, our CPU is able to spend more of its time doing actual useful work. Of course, I’m not saying that higher is always better. But I’m just saying there’s actually many scenarios where higher CPU utilization, a higher green line here, can actually be better than a lower green line. So how do you know if you have a bottleneck? Well, the way I like to look at it is I like to fire up Performance Monitor. So I’ll do that right here. And inside Performance Monitor, I’m going to add a counter, And I believe it is in my, let’s see, System. And I have a counter here called Processor Queue Length. And I’ll go ahead and close this. That’s the yellow line. We’ll go ahead and Control H to highlight that, turn it white. This Processor Queue Length, notice we have a multiplier of 10 in effect here. See, I’ve got a value of 1 or 2 or 3. This is how many operations are in the queue, how many operations are waiting in line to have access to that processor. And this is the performance metric that I want to watch to see whether my system is processor-bound. Do I have a problem where I need more processing capacity or more better management of my processing? So it’s not really about looking at the processor utilization. It’s more about looking at this processor queue length. Now, it’s not possible to come out with this specific number and say, oh well, if your process queue length goes above 10, or goes above 20, or goes above 30, or whatever that number is. You can’t really say there’s a specific number to look out for. It’s more about looking what your processor queue length is, and also looking at your processor utilization. And when your processor utilization gets high, take a look at this queue length. If this queue length is nice and low, you probably have nothing to worry about. But if you see this queue length going higher and higher, well then you might want to do something about that. And, of course, if you have to do something about that, you can either a). build a bigger server or add faster or additional processors to your server, or b). you can manage your server more intelligently, so that your existing hardware is able to be utilized in a lot more efficient way. And that’s exactly where Citrix’s CPU management technology comes into play. As I said earlier, the CPU management technology was introduced in Presentation Server 4. It was actually licensed from a company called Aurema. To use it is very, very simple. So to use it, I’m going to go back here, and I’ll access my Citrix Access Management Console. I’m just going to right click on my server farm and choose Properties to look at the properties of the farm. And if I look into my server default settings, I see in the memory CPU, I see CPU utilization management. And right there it’s a checkbox. Check that box. This now means that all servers in my farm, by default, have CPU utilization management enabled. I can actually cancel this and go into a specific server, right click Properties, and look at that same thing, CPU utilization management for this server. Do I want to use the farm setting, or do I want to override that and control that manually on a server by server basis? But I’ll go ahead and apply here. And I see now, on this server right here, CPU utilization management is enabled. And the easiest way to see sort of what that is, is let me go ahead and fire up my services. So if I look in the Services applet here. Let’s expand this out. Okay. Among all my Citrix services, I see right here Citrix CPU Utilization Management/Resource Management. This is the single service that provides the Citrix CPU management functionality. You see here the service is set to manual startup, but it is started right now because I do have this enabled. Actually, if I disable this, so I’m unchecking the box to disable CPU utilization management. I’ll click Apply and go back into my services. And if I refresh the services list here, you’ll see now that is not started because I have disabled it. But I’ll go ahead and re-enable on the farm. Click Apply. My settings are saved into my farm database and pushed down to my server. And if I come back up here and refresh my services window, you’ll see there that it is, in fact, started up. So that’s the service there. That’s the basic kind of core functionality of CPU utilization management. And using it is as simple as checking a box. It’s a one box check. Very, very cool. So now that we looked at how we turn it on, and we looked at the service, let’s look at what it actually does. Well fundamentally, the Citrix CPU utilization management service, it dynamically adjusts the priorities of the various processes. So when it gets busy, it can make sure that busy users do not negatively impact other users that are not as busy, or can ensure that important users always have the access they need to the CPU of the system. The bottom line is it tries to ensure that all users get their fair share, to use Citrix’s term, to the processor. And I talk about dynamically adjusting the priorities of processes. I want to show you something here. If I go back into Task Manager, with all the processes that are running. So go to View, Select Columns, and let’s see here, where is it, Base Priority. You see here that we have a…within this Task Manager, we can show the…that every process that runs with inside this system has a priority. And we see that priority is above normal, normal, real time. There’s different priorities of these processes. And, basically, this means that if there’s a contention, if you do not have enough CPU to…where things need to get more work done, then the system will automatically adjust the priority of the various processes that are running, in order to ensure that everyone gets fair access. And you can see right here in front of our eyes that some of these processes are changing right before us, between normal and above normal. This is the Citrix CPU management at work. This is what it does. It adjusts the proc…the priority of different processes. So adjusting the priority of different processes is kind of cool, because it’s not limiting. It’s not specifically capping what certain processes can do. It only kicks in when the system is busy and dynamically adjusts the priorities of these different processes. So let’s look at this a little bit more in depth here. You know, the first question everyone asks is, okay, does it work? Well the answer is, absolutely yes. It’s very, very cool. And as I said earlier, CPU utilization management, I think, is one of the best features of Presentation Server that really not a lot of people know about, and not a lot of people use. But it’s pretty cool stuff. A couple other things I want to mention is that this whole thing is based on what I will call soft limits. So what I mean is, what’s cool, is if you use Citrix CPU management to, let’s say, reserve a certain percentage of the CPU for a certain user, and we’ll look at how to do that more in a minute. But if I use it to reserve a certain percentage for a certain user, it only limits other people when the system is busy. So what I mean is, if I reserve 20% of the system for one user, that means that one user will always get 20%. But if that user is not doing any work and doesn’t need 20%, the excess can be used by other things on the system. So you can set limits that happen when contention takes place. But if there’s no contention by the user who needs it, it will flex and let the system grow and breathe as needed. But the problem with it is you’re not going to know it’s working just by looking at Task Manager. Because, remember, Task Manager, it’s just showing that green line that’s showing overall CPU utilization. Well Citrix’s CPU management, it doesn’t really effectively do anything until a system is really busy. And because it’s all soft limits, when the system is busy, you’re still going to see the CPU just as utilized as it ever was. It’s just that CPU management is actively managing who has access to the CPU. So you cannot simply look at Task Manager to see if it’s working. You actually have to look into Performance Monitor. And we’re going to take a look at this in a little bit in Performance Monitor and see exactly how it works. And, in fact, we’ll show how it works. But before we do that, I want to go over some more vocabulary. Basically, there’s two things you have to know when you’re thinking about how CPU management works. The first thing is that, on a user by user basis, you can configure something called shares, and you can configure something called reservations. So the shares and the reservations. This is something that you, as an administrator, configure yourself. And then, based on those settings, the system, it looks at your settings. It looks at the shares and reservations you’ve set. It looks at the current overall CPU utilization. It kind of mixes all that together, and it creates and figures out these things called entitlements, which figures out what percentage of the CPU each user is entitled to use. So let’s look at this a little bit more in depth for these per user settings. The first thing, as I said, you can configure is something called a share. And a share is a numeric value between 1 and 64. And it’s not based on percentage, it’s just some kind of made-up number. But the way the shares work is that, by default, every user who logs onto a Citrix server has a share of 8. So two users logged on at the same time means each user has a share of 8. The total shares is 16. Each user has half the system, basically. If you have 10 users logged one, they all have a share of 8. That means the total shares is 80, and each user gets 10% of that system. If you have some users, though, who are not important, and you want to give them less of a share, you can actually create some registry keys and say, hey, I want these users to have a share of 4, which is half of the other users. Or a share of 2, which is a quarter of the other users. Or for your more important users, maybe you give them a share of 16, or 32, or 20, or something like that, to give them a bigger share. And, again, a share does not really map out to a specific percentage. A share is more about the relative share of some users compared to the baseline share of 8 for everyone else on the system. What’s interesting about these shares also is, again, these are all soft limits. So the shares don’t matter if you’ve got plenty of CPU available. If you have 50% available or whatever, that’s fine, and the shares are not even going to take affect at all. The shares don’t really matter until your system gets really busy, and your CPU gets really busy. Then it…the system will use these shares to figure out, okay, how do we take this precious CPU resource and divide it up amongst our users. So that’s our shares. It’s a relative portion from one user to the next. The next thing you can do is to configure a reservation. A reservation is a specific percentage of the system CPU resources that are reserved for a particular user. Now the reservations are actually expressed in thousands. So if I want to reserve 20% of a CPU for a specific user, I enter the value 20000 for that user. Or reserving 1% is reserving 1000. Now, what’s interesting, again, these reservations are also soft limits. So if I reserve 20% for one user, it that user does not use all 20%, the extra portion is available for other users to use. It’s just that if any process of that user comes on, that process is going to get priority to be able to use up to its 20%, or whatever it is that you’ve configured. So these are what you configure, the share and the reservation for the user. Now, as I said, based on that, the system works out something called entitlement. And the entitlement is what percentage of the CPU overall is available for any given user. And again, that’s based on shares and reservations and, really, the recent CPU utilization. Because again, if CPU utilization is not high, there’s not really too much need for the system to jump in and start messing with things. At what point does the system kick in and start managing? Well it just depends on what your shares and reservations are. If you have a reservation of 75% for one user, that means even as little as 25% utilization, the system needs to kick in and start doing some management. But maybe in some cases, this is much, much higher, and the system does not kick on nearly as much. That said, let’s actually look at this configuration. I told you you can configure these shares and these reservations. Let’s take a look at this. Now, unfortunately, in order to do this, we have to go into the registry. So I showed you in this Access Management Console where you have this checkbox, turn on CPU utilization, or turn it off. That’s the only option we have. Well, okay, fine. There’s no options here in this graphical interface for configuring shares and for configuring reservations. So I’m going to go ahead and go into the registry. And let’s start from the top here and look at where this is actually stored in the registry. So HKEY_LOCAL_MACHINE, SOFTWARE, Citrix. This is where everything is, right? HKEY_LOCAL_MACHINE, SOFTWARE, Citrix, CTXCPU. So this CTXCPU key, this is the location where the system manages, or where it holds all of the settings for memory of…pardon me…for CPU optimization management. And there’s one option here, it’s called Policy. I want to double click this. And see this multi-string registry value is where we configure these shares and reservations on a user by user basis. Now see this very first line here? It says NT AUTHORITY\SYSTEM, cpu.reservation=20000. I did not enter this option in here. This is actually, by default, included with the system. So when you install Citrix, it…what this is doing, basically, is it’s reserving 20000, which is in, you know, thousandths of a percent. This is reserving 20% of a CPU for the system. So for your kernel and things like this. This is the only setting that Citrix provides by default. It reserves 20% of a CPU for the kernel. Everything else is fair game. Of course, since these reservations are specified on a system-wide basis, and since Citrix wants to reserve only 20% of a single CPU for system tasks, if you have a multi-processor system, you’ll see that value of 20000 will be adjusted automatically when the Citrix product is installed. So dual processor system, you get a value of 10000, quad processor a value of 5000, etc. That’s the key to remember, is that these reservations are reserving a percentage of the system overall. You see here, I can add some additional entries based on user name, domain\user. And you see I can enter reservations, which, remember, these reservations are based on thousandths of a percent. So these values of 10000 are reserving 10% of a core for the user brian, and 10% of a core for user administrator. And I can also enter my shares here for a specific user. And again, remember by default, all users have a share of 8. Here I’ve given the user brian a share of 16, which essentially doubles the share that brian gets compared to the rest of the users. So, like I said, in order to see this, we have to use Performance Monitor. So let’s go ahead and do this. So I’m going to open up Performance Monitor. Let’s just delete all my other counters that are showing right now. I’ll click the Add button. And look at my process objects. I have an object here called Citrix CPU Utilization Management. And if you look here, I’ve got, well, just the things we’ve talked about: CPU entitlement, reservation, shares. And then CPU usage and long-term usage. And then I also have a listing of all the users who are currently logged in. So let’s take this administrator. I’m going to add entitlement. I’m going to add reservation. And I’m going to add shares for our administrator user. By the way, if this is ever grayed out and not available, that just means that your Citrix CPU management is disabled and that service is not currently running. So let me close this here. And now if I look at the shares for my administrator user, and I look at the reservations, I can see, ah, I see a reservation of 10% here. And that’s because if I go back into registry editor, I see here administrator has 10% reservation, based on 10000. Let’s change this to 15. Okay? So I’ll change that to 15% for the administrator. Click OK. Go into Services and restart the service. Now go back into Performance Monitor, and there you see all these bumped up to a reservation of the 15%. So that’s very cool. Now let’s actually go ahead and pull in an additional user here. And so to do this, let’s see, I’ll go out to my desktop, because I have an icon here for my web interface. And I’m going to log on as brian, because before, I’m currently logged on now as the administrator. So log on as brian. And let’s fire up Calculator for brian. Okay. All right. So now brian is running Calculator. And I’m going to go back into Performance Monitor, and I will go into…back to my CPU utilization management. And now we see brian on the list here. Let’s add these three counters also for brian. There we go. And so now we can see brian’s reservation is 0, because I don’t believe I configured that. Ah, now look at that. I see my CPU shares for brian is 16, because, as I recall, if I go back into registry editor and look here, there it is. I have made shares of 16 for the user brian. Of course, the administrator shows shares of 0, because I have not configured any shares for that user, although, technically, like I said, all users have a baseline share of 8. So even though administrator shows my shares of 0, that’s more because I’ve not overridden the basic defa…the baseline, I should say, of 8 shares. And then, I can also see something here called the entitlement. Now the entitlement is interesting. The entitlement is actually a percentage of CPU that that user is entitled to. So, like I said, you do not configure entitlement yourself. The system actually works out entitlement on its own, based on the shares and the reservations and the current CPU utilization of the system. So, when should you use CPU management? Well, to be honest, it really doesn’t hurt to have it enabled always. I feel pretty confident saying that if you want to turn it on, or if it’s not turned on right now, go ahead and turn it on. Now, again, you’re not going to see the benefit until your server’s really busy. So if your CPU is not kind of up there towards, you know, full utilization, it’s not really going to make a difference, because you don’t have a problem anyway. But there’s no downside to using it. And, in fact, it will typically allow you to fit more users on a busy server, or at least to provide a better experience, a more consistent experience, for the current number of users you have on a busy server. Now CPU management should be completely transparent to the applications, although some cases, some security software will identify it as a threat. If this is the case, it’s no problem. You can actually go in the registry and exclude certain executables for being managed by CPU management. And by the way, the process, it’s a service, like I said, but if I go back into Task Manager, you will see this ctxcpusched.exe service. Look it…it’s running in real time, the very highest priority, because this is the actual process, the actual service that’s affecting the schedule that are…pardon me, that’s scheduling your different processes and actually affecting the priority of those processes. So I say turn it on all the time. It can’t hurt. Down sides. Well, like I said, the down sides is, the only graphical option you have is to turn it on, turn it off. If you want to tune this, you have to do it via the registry. Which means you have to do it on every server manually. Of course, you also can apply this value via group policy, but it’s something you have to do via each server. The other down side is it’s only tuned per user. You cannot tune it per group, or per published application, or anything like that. So when you’re creating those registry values and modifying that multi-string key, you’re adding users into that group. So you might have to spend a lot of time or write some scripts or something to enumerate that your users and add all the users in there. But beyond that, it’s good stuff. It works. It works well. It just kind of sits there quietly and does its thing in the background. And on busy servers, it really will allow you to get more users on your box. So we like it a lot. Now the second half of our video is Citrix’s Memory Optimization Management. Memory optimization management is really the companion of the CPU optimization management we discussed in the first part of the video. And, actually, much like the CPU management, the memory management also was introduced originally in Presentation Server version 4, and moves forward into Presentation Server 4.5 basically unchanged. Citrix also went to a third party company to get this technology. They actually licensed it from RTO Software. RTO had this product which was called TScale. And, basically, Citrix licensed TScale and essentially built this into the Presentation Server 4 and 4.5 products. So the technology that Citrix memory optimization management uses is something that’s called DLL Rebasing. And so to understand how to use memory optimization management and really where it works, you really have to understand what DLL Rebasing is. Now I apologize. There’s a couple of words on the slide here, but I figure you can pause the video and read this if you want to. But let me try and explain it to you. Basically, whenever a programmer compiles a DLL, that DLL is hard coded to load itself into search and memory address. So then whenever two DLLs are hard coded for the same address, or hard coded for any parts of the addresses that would overlap each other, they would conflict because it can’t load, you know, two different DLLs into the same physical area of memory. And it’s okay when this happens. I mean the system takes care of this when it happens. The system will basically move one of these DLLs on demand when it loads to a different area in memory. And, again, that’s basically okay. But the problem is this DLL is hard coded and programmed to be loading into a certain area in memory, and it’s having calls in that area and areas relative to the first area, and everything like that. So, basically, if one DLL is moved on demand, it takes…it’s a lot of extra work for the system, not only to move it, but to kind of remap every call back and forth between the DLL and the memory area. It’s a very “expensive” process. I put expensive in quotes, because it’s expensive in terms of performance. It’s expensive in terms of page file utilization. It’s just a very…a very expensive process, especially in an environment like a Citrix Presentation Server, where you have many copies of the same DLLs, and many different applications loading, and really can bog down the performance of your environment. So, this is the problem. Well, what would be cool is, if there were two DLLs that were hard coded to conflict with each other or where they would overlap. Wouldn’t it be cool if we could just sort of change the code of those DLLs so that they did not conflict with each other? Yeah, of course, it would be cool. And this is exactly where Citrix’s memory optimization management comes in. The way Citrix memory optimization management works is, there’s a service, a Citrix memory optimization management service. It actually sits there and just watches the system all day long. It watches every DLL that’s loaded in every session. And it looks at where that DLL is hard coded to load and compares that to where the system actually loads that DLL. Whenever it sees a difference, the service makes a note of it. Then, whenever the system is restarted, or additionally at an interval you specify via the Management Console, the memory optimization management service writes out some new code for the DLL, and it stores it in what’s called that file’s alternate datastream. So what happens is, you have the original file, and you have an alternate version of the file. Now, to take a step back, when Presentation Server is installed, it also installs a file system filter driver. This file system filter driver is invoked whenever DLLs or executables are read from disk. So in the case where Citrix’s memory optimization management has written to the alternate datastream, then that filter driver kicks in and pulls the modified code segments from the alternate stream. So, hopefully, you can follow that. In a sense, what this means is that Citrix is able to recode, if you will, conflicting DLLs and executable on a case by case basis without actually changing a physical file. Simple. So, does it work? Yes. For most applications. There’s a few applications where it doesn’t work. Sometimes the applications themselves are written in such a way that they will not conflict with multiple instances of themselves or other applications. And sometimes the applications just are not cool with this. Like, for example, some applications maybe are anti-virus software. And when they see the system trying to change the executable via this alternate datastream, they’re not going to be happy with that. Another problem is that in order for this alternate datastream to be written, the application has to not be running currently. So it doesn’t work for any system processes or things like that, that are always running, because it can never actually write out that alternate datastream. Sounds cool. How do we turn it on? Well, I’ll go back out here to the Management Console. And much like the way that we configure Citrix CPU management, this is also how we configure the memory management. So I go to my server default settings on my farm, memory optimization. It’s just tick box. Turn it on, turn it off. And if I go into my services control panel…pardon me, my services management console, you will see here Citrix Virtual Memory Optimization. Again, this has started. If I tick that box and disable, then I will see that this process will stop. So the Citrix Virtual Memory Optimization is the actual service that runs…that takes care of this. So let’s actually kind of see this thing in action, because it’s kind of cool. The way I’m going to do this, let me jump back on to my desktop. Actually, first I’m going to start some applications. So let’s start up Acrobat Reader. Let’s start up Visio. I just want to get some applications running. Click this thing since I’m using NFR licenses. Thank you, Citrix. So, let me just fire up a couple applications here. So there we’ve got Visio, there we’ve got, now, Acrobat Reader running. Okay. Let me jump onto my desktop of my Presentation Server. And I have here the application called Process Explorer. So Process Explorer, you can get this from Sysinternals. Let me open up a new tab here, and it’s on my Favorites. So just Google search for Process Explorer. As you know, I think everyone knows, that Sysinternals was bought by Microsoft, and now these are all free and available from Microsoft. So I’ve got Process Explorer running. And Process Explorer has a whole bunch of details about running processes that are within our system. So what I want to do here, first, I want to go to my View menu. And for the lower pane view, make sure this lower pane view is set to DLLs. So now my lower pane is going to show DLLs that are loaded for specific processes that are highlighted in my top tab. So there I’ve got my DLLs. And let’s see, I should build a…see here, for example, like Acrobat Reader. Okay. So here’s all the DLLs that are loaded. The next thing I want to do is, on my View menu, I can do, let’s see, select columns. And so, for the DLLs area, I have base address and image base address. So let’s check those and enable both of those. And what this does, the base address, this is showing the base address where that DLL is loaded in memory. The image base is the base address that’s hard coded into the image of the file itself. In other words, this here image base is the base address in the actual DLL. This base address column is the base address that’s actually in memory. So all we need to do is to see when two DLLs are sort of crashing into each other, and the system is having to dynamically remap them. Just look for differences here. Look for any time we see a different base address from image base. So, of course, we can go through this manually, oh, there’s one right there. It’s much easier, though, I can also go to my options menu and do Configure Highlighting. And, by default, relocated DLLs is not highlighted. So I’m going to go ahead and click OK. And now we see I have some yellow highlights here. Every time I have a DLL that had to be remapped on load, I now have the yellow highlight here. So here’s all the ones for Acrobat Reader. And here’s all the ones for Visio. And I can really look through this whole thing and just see all sorts of different DLLs that had to be remapped on run time. So the question is, is Citrix’s Memory Optimization Management good for you? Well, really, you can just fire up this free Process Explorer, do the highlighting and column viewing I showed you right here, and just kind of click through the stuff. And just kind of see, within your environment, everything that has been remapped. Look at this, again, when you have multiple instances of the same application running, this is when it happens big time. So, you know, I had within one session running Acrobat Reader. Let’s fire Acrobat Reader up now in my console session. I’ll wait for that to load. So now, let’s look at the Acrobat Reader in my console session. Man, look at all this stuff down here that’s now rebased because there’s just so, you know, much multiple instances of it. They’re not able to both be loaded in memory at the same time. So this is a scenario where I would want to enable Citrix Memory Optimization Management. Now I want to go back here into my Access Management Console and point out a few things. So server defaults, it’s just tick box. Turn on or turn off. I do want to go back to my farm-wide settings and point out a couple of things. First of all, I have this thing under memory CPU called Optimization Interval. So, remember, I told you how memory optimization works? It sits and watches all day long. It’s basically recording the same thing we’re seeing in Process Explorer. It’s recording all the times that DLLs are loading into a different location than what they’re hard coded to. And then we set, like I said, by default, once a night at 3:00 a.m., it’s going to go through and actually try and write out the new mappings and new addresses into these alternate datastreams for all those DLLs. This is where you configure that. Probably 3:00 a.m. by daily is fine. But like I said, the applications have to not be in use when this happens, in order for it to write out to them. So the other thing we have here is excluded applications. So, as I said, here we can make a list—of course, this is farm-wide—but now we can make a list of specific executables that it should not try to optimize. And, of course, it’s not actively optimizing executables. Well, it is, but it’s looking at executables and their affiliated DLLs. Now, one thing I’ll point out, too, is, yeah, let’s kind of go nerdy here. Let’s go back into registry and cancel out of here. Because, remember, we were in my computer, local machine, software, Citrix. Earlier we looked at ctxcpu for the CPU optimization management. Let’s also look down here under SFO, which I actually don’t know what SFO stands for. System File Optimization? I have no idea. I’m making that up. But you see in here, we have a bunch of, by default, components that are excluded. So here’s processes that are excluded by default by Citrix. Here’s components, the DLLs, that are excluded by default. So there’s a whole bunch of stuff that Citrix, out of the box, knows that it should not try to optimize. But via this Management Console, you’re able to actually add your own exclusion list. So, the problem with this, or I guess I’ll call it a problem. You know, one of the main sort of down sides of the memory optimization management from Citrix is just that people will use it. They turn it on, and they find some application that it doesn’t work for. And maybe it breaks that application. Maybe that application doesn’t load. And they say, ah, man, this memory optimization management is total garbage. I don’t even want to use it. When the fact is, it’s not really even that memory optimization is bad. You shouldn’t indict the whole thing just because you found one application that it doesn’t work for. And I think you’re really doing yourself a disservice. So I think, you know, by using the Process Explorer, you can see how valuable it could be for you. And then by using the Management Console and those farm settings, you can actually configure so that you exclude these applications that it might be causing problems with. So, like I said, down sides. It doesn’t work on all applications, because not all applications benefit from it. And, in fact, it can break some applications. So it might take you a little bit to kind of get it worked out and figure out how to do it. So a couple, few little down sides to it. But overall, again, I think memory management is cool stuff. To summarize. I love CPU management. I love memory optimization management. CPU management, you can turn on always and basically just leave it on. You can tweak it if you need to. Memory management, turn it on, see if it works. If it’s breaking some things, you can exclude those specific things, and it’s cool stuff. So, resources. What do you need to do for this? I mention a couple of things. Streams. I did not talk about the streams executable, but there is an executable out there from Sysinternals called Streams, which allows you to view the alternate datastreams, and delete, by the way, the alternate datastreams associated with specific executables and DLLs. So that’s out there. Process Explorer. I showed you how to use that. Citrix has a couple knowledge base articles: 106021 and 106023. 106021 is a very technical detailed description of how CPU management works. And the affiliated description for how memory optimization management works is that 106023. So, with that, I thank you for listening. And I hope that you found this presentation valuable. And if you don’t have these things turned on, go out there, get them turned on. Because this is a real great value. It’s a real great add-on for the Enterprise and Platinum editions of Presentation Server. And I think it’s something everyone needs to know about. So, again, my name is Brian Madden. Thanks for listening, and happy Citrix.
anonymous - Video is way ahead of the audio.
davidwag - thanks for pointing that out and sorry I missed that. It is corrected now and should play correctly.
anonymous - Thank you! This video is great at providing insight into the inner workings on the CPU and Memory usage in Citrix. These are GREAT tools to implement and you should watch this video. They will make your users happy and their Citrix sessions better. Not to mention Brian Madden is the defacto standard on optimizing anything with Citrix! kudos to David for posting it and Brian for providing the video!
agugoasa - Exellent demo!<br>How much overhead is the remapping of the calls to DLLs adding to the system though? Is it worth risking breaking applications and troubleshooting for the ?% of the CPU gained with the memory management?<br>Thank you.<br>