Using Lazy Builders and Auto Placeholders in Drupal 8
I’ve been working on a site that features a lot of user-specific customization and output. The site offers workshops (courses) using the Opigno LMS for Drupal 8. The workshops are rendered in a few different ways throughout the site. For the most part, the rendered workshops appear the same for all users. Here’s an example of a “card” view mode for a workshop:
If a user has successfully completed a workshop, a special badge will appear on the card view mode. Also, the card will be highlighted:
There are two parts of the workshop card template that have to change based on the user viewing the card:
Mac High CPU Usage – WindowServer
DISCLAIMER: I’m writing about my personal experience here. I am by no means doing some exhaustive investigation. The changes I explain below seem to make a difference, at least according to what Activity Monitor is showing for CPU usage.
My laptop (3.1GHz i7 MacBook Pro with 16GB of RAM) has enough of power, so why has it been such a dog since starting from scratch with a fresh OS? A colleague posted an animated Gif today in Slack and my MacBook fans kicked in and it sounded like it was getting ready to fly away. This was the last straw in what has been weeks of wondering why my laptop has been slow.
I opened Activity Monitor and found that my WindowServer process was using a significant amount of CPU resources (up to 77% when the animated gif was visible on my screen), and that it has used significantly more than the next heaviest process since I last rebooted.
I understand that it’s probably a pretty heavy process, but it got me thinking, and Googling. As it turns out, when something is being drawn to the screen it takes processing power; go figure! One of the top suggestions was removing or disabling things from the menu bar that are constantly updating. The suggestions included CrashPlan and Little Snitch Network Monitor. Wow. I use the latter! I opened the Little Snitch preferences and unchecked “Show network activity in menu bar” and voila! the WindowServer process memory dropped about 15%. Then I closed the animated gif my colleague posted in Slack (the only other thing on the screen that was moving) and voila! it dropped again.
Now, as I’m looking at my CPU Time in Activity Monitor I’m thinking through what I really need running. Is the “Next Meeting” (which shows the name and time of my next meeting in the menu bar) application really worth running 24/7? I don’t think so; especially if I have more important things for my CPU to be doing. After quitting this application my WindowServer CPU usage dropped to 6.6%.
I’m going to continue to trim the fat to see how lean I can make my machine. Obviously it doesn’t stop at just trimming out running applications, but I’m blown away by the impact of small changes like these.