How to make authentic jitrnice at home (Follow this easy step by step guide for delicious results).

0
20

Alright, let’s talk about this jitrnice thing I played around with recently. It wasn’t some fancy downloaded tool, more like an idea I tried to make work myself.

How to make authentic jitrnice at home (Follow this easy step by step guide for delicious results).

Figuring Out the Problem

So, I had this script, you know, one of those background tasks that chews through a lot of data. Whenever it ran, my whole computer would slow down, like wading through mud. Just trying to type or browse became a pain. I already knew about the basic `nice` command, which helps a bit by setting a process priority from the start. But that’s static, right? It’s always set low priority, even when I’m not using the computer much. I wanted something smarter, something that would be ‘nice’ only when I needed the responsiveness back. That’s where I started thinking about this ‘just-in-time nice’ or jitrnice concept.

My First Attempt

I opened up my terminal. First thing, I needed a way to check if I was actively using the machine. My first thought was just system load average. Simple enough.

So, I started cobbling together a little shell script. Just a basic wrapper. The plan was:

  • Start the heavy data script (`data_*` I called it) normally.
  • In a loop, check the system load average using `uptime` or something similar.
  • Find the Process ID (PID) of my `data_*` using `pgrep data_cruncher`.
  • If the load average was high (meaning I was likely doing stuff), use `renice` to increase the niceness value of the script (like `renice 19 -p PID`). This makes it lower priority.
  • If the load average was low (meaning the computer was mostly idle), use `renice` again to decrease the niceness value (like `renice 5 -p PID` or even `0`), giving it more CPU time.

Getting the PID dynamically with `pgrep` was key. Then I just put the `renice` commands inside an `if/else` block within a `while true; do … sleep 5; done` loop. I set it to check every 5 seconds or so.

Testing and Tweaking

I fired it up. Ran my `data_*` through this new wrapper script. Kept `htop` open in another window to watch the ‘NI’ column for my script. It was pretty cool seeing the nice level actually change!

How to make authentic jitrnice at home (Follow this easy step by step guide for delicious results).

Then I started using the computer like normal – opened a browser, typed some stuff, moved windows around. When I did that, I watched the load average go up, and sure enough, my wrapper script kicked in and `renice`d the data cruncher to `19`. The desktop felt way more responsive, not perfect, but much better than before.

When I stopped messing around and let the computer sit idle, the load average dropped, and the script `renice`d the data cruncher back to a lower number, letting it run faster again.

What I Found Out

It sort of worked! It definitely made the system feel less sluggish when the heavy script was running and I needed to do something else. That was the main goal.

But, using just the overall system load average wasn’t the smartest trigger. Sometimes other background stuff might spike the load, or maybe my own activity wasn’t heavy enough to push the load past the threshold quickly. There was often a slight delay before it adjusted. Finding the right load average threshold took a lot of guessing and checking.

Also, constantly checking and running `renice` probably adds a tiny bit of overhead itself, but it seemed worth it for the improved usability.

How to make authentic jitrnice at home (Follow this easy step by step guide for delicious results).

So yeah, that was my little experiment with this jitrnice idea. Didn’t find a magic tool, just hacked together a script based on the concept. It’s not super sophisticated, but it was a practical step that made a noticeable difference for my specific problem. It’s better than just setting `nice 19` and letting the script always run slow.

LEAVE A REPLY

Please enter your comment!
Please enter your name here