Why do processes hang randomly while my Mac is locked - macos-catalina

This is on an iMac (late 2015) running MacOS Catalina. All energy saving options are off.
I have noticed this with several long-running processes and so I made a simple example.
I ran
while true; do date; sleep 60; done
around 11 am and let the screen lock. After a few hours I come back and check on it. Everything is fine for about an hour and a half, i.e. I do get one line per minute and then
Mon Feb 6 12:32:39 CET 2023
Mon Feb 6 12:33:39 CET 2023
Mon Feb 6 12:41:33 CET 2023
Mon Feb 6 12:43:08 CET 2023
Mon Feb 6 12:52:57 CET 2023
Mon Feb 6 13:28:00 CET 2023
after which it goes back to normal for about half an hour and then starts being erratic again.
Experience shows with other long running processes that the times this happens are fairly random.
Ideas on how to avoid this? I want my processes to run normally. Thanks.

As #Rob mentioned in his comment yesterday, turning off power nap in Energy settings seems to solve this problem. (I had a chance to test it for several periods now, including overnight.)
Thanks!

Related

FFMPEG and AWS: What's the most efficient way to handle this?

I'm new to AWS and I originally built the FFmpeg functions on my Node.JS API. But I realized this is the wrong way to do it in a real-world app, and that you need to use separate Lambda functions in AWS that handle the video editing separately from the main server.
I'm mainly a front-end developer but I'm open to learning new things.
I basically have the following process in my app:
User uploads video.
I need to take that video and add a watermark to it.
I then need a copy of the watermarked video in a smaller resolution.
I then need a 6 seconds GIF of the smaller resolution video.
Finally, I need to upload the 3 edited files (2 .mp4's and 1 .gif) to S3, and remove the original, non-watermarked video.
Here are my questions to be clear:
Should I upload the original file to S3 or to the server? And why?
Is the process above doable in a single Lambda function? Or do I need more Lambda functions?
How would you handle this problem, personally?
I originally built it by chaining one function to the next with promises, but AWS seems like a different world of doing things and the way I originally built it would not work.
Thanks a lot.
Update
Here are some tests I did with a couple videos:
Test 1
Test 2
Test 3
Test 4
Test 5
Original video resolution
1080p
1080p
1080p
1080p
480p
Original video duration
23 minutes
15 minutes
11 minutes
3.5 minutes
5 minutes
Step 1 duration (Watermarking original video)
30 minutes
18 minutes
14 minutes
4 minutes
2 minutes
Step 2 duration (Watermarking lower resolution)
5 minutes
3 minutes
3 minutes
1 minute
skip (already low res)
Step 3 duration (6 seconds GIF creation)
negligible (15 seconds)
negligible (10 seconds)
negligible (7 seconds)
negligible
negligible
Total
~35 minutes
~21 minutes
~17 minutes
~5 minutes
~2 minutes

boost::log with multi-process

I have asked a question about how to use boost::log in multi-process
How to use Boost::log not to rewrite the log file?
That answer can solve most part of the problem. But in some rare case, when one process is writing log and another process is starting to write log,
13548:Tue Nov 30 17:33:41 2021
12592:Tue Nov 30 17:33:41 2021
13548:Tue Nov 30 17:33:41 2021
12592:Tue Nov 30 17:33:4572:Tue Nov 30 17:33:41 2021
17196:Tue Nov 30 17:33:41 2021
8572:Tue Nov 30 17:33:41 2021
17196:Tue Nov 30 17:33:41 2021
8572:Tue Nov 30 17:33:41 2021
The fourth line 17:33:4(1 2021) the rear part was erased with (8)572:Tue Nov which was written by the other process.
How do I prevent this?
Boost.Log does not synchronize multiple processes writing to the same file. You must have a single process that writes logs to the file, while other processes passing their log records to the writer. There are multiple ways to achieve this. For example, you can pass your logs to a syslog service or writing your own log writer process. In the latter case, you can use inter-process queue to pass log messages between processes.
Alternatively, you can write your own sink backend that will perform synchronization when writing to a shared file. However, I suspect the performance will be lower than having a single log writer process.

calculation of unix time from utc time on ubuntu

I am using ubuntu 18.04 on my machine. My ntp is configured to use gpsd as a source. Time provided by gpsd does not consider leap seconds but NTP adjusts it and provides UTC with leap seconds adjusted. So my system clock will be synced to UTC by NTP. From the documentation, std::chrono::system_clock::now provides time since 1970 and does not count leap seconds.
My question is does the kernel adjusts leap seconds when we call this? Or the time queried from std::chrono::system_clock::now is actually contains same time coming from NTP which has leap seconds adjusted.
system_clock and NTP both "handle" leap seconds the same way. Time simply stops while a leap second is being inserted. Here I'm speaking of the time standard, and not of any particular implementation.
An implementation of NTP might not stop for a whole second during a leap second insertion. Instead it might delay itself by small fractions of a second for hours both before and after a leap second insertion such that the sum of all delays is one second. This is known as a "leap second smear".
So you could say that both system_clock and NTP ignore leap seconds in that if you have two time points t0 and t1 in these systems and if t0 references a time prior to a leap second insertion and t1 references a time after that leap second insertion, then the expression t1-t0 gives you a result that does not count the inserted leap second. The result is 1 less than the number of physical seconds that has actually transpired.
A GPS satellite "ignores" leap seconds in a completely different way than system_clock and NTP. The GPS "clock" keeps ticking right through a leap second, almost completely ignoring it. However GPS weeks are always exactly 604,800 seconds (86,400 * 7), even if a leap second was inserted into UTC that week.
So to convert GPS weeks (and GPS time of week) to UTC, one has to know the total number of leap seconds that have been inserted since the GPS epoch (First Sunday of January 1980). I believe gpsd does this transformation for you when it provides you a UTC time point.

URLFetch Max Deadline is Only 60 Seconds for TaskQueues

Problem:I am calling URLFetch with a deadline of 480 seconds from
within a TaskQueue, but it is timing out after only 60 seconds.
The original question was asked in official group more than year ago, but still unanswered.
Bug confirmed, but there is no technical support or developers of gae. Maybe they're here?
While there is information on this old thread that suggests otherwise, I don't believe this is a bug that will be fixed (or that it is a bug). It's unfortunate that this issue has not been updated or closed.
A Urlfetch (regardless) of where you make it from within appengine world has a maximum deadline of 60 seconds.
Requests on front end instances within appengine also have a lifetime of a maximum of 60 seconds.
Requests within the context of the Taskqueue however, have a lifetime of up to 10 minutes. This however does not mean that you can make a Urlfetch made from within the taskqueue context exceed the 60 second deadline.

Synchronize system clock with UTC time using C uder Window OS

I have UTC time which is coming from UDP, I have a program to calculate Day and Time of UTC, how can I set my system clock at that day and time, kindly give me some direction so that I can make it possible.
I am using Window OS.
To set the current system time, use the SetSystemTime Win32 API function.