Post

Replies

Boosts

Views

Activity

Nice vs Priority on MacOS
I write programs to do calculations. In order to automate some things I setup my Mac to consume a queue of jobs and a cron will check the queue and then run them through. I noticed that cron jobs run so much slower. As root I am running all the commands at nice -n -100 (yes I know -20 is the limit) if I run this command from the terminal it take 62 seconds. Checking the ps this is what I see: UID PID PPID F CPU PRI NI SZ RSS WCHAN S ADDR TTY TIME CMD STIME 0 17826 17195 4006 0 31 -20 413217088 581472 - R<+ 0 ttys000 16:11.07 /usr/local/bin/M 0.358 12:41PM Now comparing that to the cron'd job this same calculations will take 441 seconds. The ps comes out to: UID PID PPID F CPU PRI NI SZ RSS WCHAN S ADDR TTY TIME CMD STIME 0 18231 18230 4004 0 20 -20 411514512 515632 - R< 0 ?? 28:16.72 /usr/local/bin/M 12:47PM This is 7x slower! Both processes are at -20 NICE, but the priority for the cron job is 20 while running from terminal is 31. So I am guessing that priority is the mitigating factor here. I can't seem to figure out how to change the priority of the job. Lots resources out there just seem to think by changing nice you also change priority. But that is not the case. The question I have is how do I change the priority of a cron job (or any job in fact). I am running on a MacBook Pro (2013). I was thinking maybe Apple Mac Pro desktops could be setup differently but I just don't know.
2
0
558
Jul ’24
How to get Command Line Tool code to launch SwiftUI App code
For MacOS I wrote a Terminal Command Line Tool to help me do number crunching calculations. No need for UI. This works great as-is, but there are opportunities to make the work more interesting by giving it some graphical representation like a heat map of the data. To that end I want the terminal to launch a SwiftUI code to open a window given an optional command line parameter that would display this visual representation of data in a new window. It would be nice to interact with that window visualization in some ways using SwiftUI. I originally thought it'd just be as easy as creating a SwiftUI View file and then throwing what normally appears under @main into a launch function and then calling the launch function from my main.swift file: import SwiftUI struct SwiftUIView: View { var body: some View { Text("Hello, World!") } } #Preview { SwiftUIView() } func LaunchSwiftUIApp() { //@main struct SwiftUIApp: App { var body: some Scene { WindowGroup { SwiftUIView() } } } } Of course this doesn't work. I've already have the command line code just spit out various png files via command line so looking to make those visualization a little more interactive or readable/organized by coding some SwiftUI stuff around those current visualizations. Anyway. Looking around this doesn't seem to be a thing people normally do. I'm not sure how to setup the Terminal Command Line Tool code that I wrote to optionally launch into SwiftUI code.
1
0
437
Jul ’24