Wrote a post about my experience with Termux on Android.
It was an exciting journey that took me two full weekends and some air travel time. Worth every minute of it.
I documented all the steps and some afterthoughts, and hope you find them interesting too.
It was an exciting journey that took me two full weekends and some air travel time. Worth every minute of it.
I documented all the steps and some afterthoughts, and hope you find them interesting too.
Hmm, let me get this straight, just to be sure I'm not missing anything important.
So, Windows 11 apparently has Windows Subsystem for Android (WAS). Much like it has Windows Subsystem for Linux (WSL).
I stumbled upon it by accident by trying to install an "app" from Microsoft App Store. The Fidelity app, to be precise. This installation attempt has installed the Amazon App Store. Instead or beforehand or whatever, don't ask, I'm not a Windows expert. Presumably, this Amazon App Store [app] would enable me to install the [Android] Fidelity app.
Well, that Amazon App Store [app] prompted me to log into my Amazon account, which I, of course, refused to. Then I've uninstalled this Amazon App Store [app] right away.
This has immediately uninstalled the Windows Subsystem for Android. Jeez.
Now, I've googled around. Binged, to be precise. And found out that that the easiest way to install the Windows Subsystem for Android is to install ... the Amazon App Store [app]!
Fine. Installed the Amazon App Store [app]. Ignored it entirely. Enabled Development Mode for this "in-Windows" Android. Then
And now
I took a random
It installed via
In five clicks I was able to listen to Douglas Adams. From a native app. Running on my Windows 11.
And now I'm finding myself in this attached comic strip. Because this, obviously, is the worst user experience imaginable. Or is it the best one? 🤔
PS:
I'm too old for hacking these days, but I would have spent some time this long weekend to install an Android emulator under
So, quite seriously, Windows 11 is not only the most developer-friendly system I know of for ARM laptops. It's also giving me those unforgettable Windows XP vibes, where things just worked, and the UX was not laggy at all.
Kinda surreal if you ask me.
So, Windows 11 apparently has Windows Subsystem for Android (WAS). Much like it has Windows Subsystem for Linux (WSL).
I stumbled upon it by accident by trying to install an "app" from Microsoft App Store. The Fidelity app, to be precise. This installation attempt has installed the Amazon App Store. Instead or beforehand or whatever, don't ask, I'm not a Windows expert. Presumably, this Amazon App Store [app] would enable me to install the [Android] Fidelity app.
Well, that Amazon App Store [app] prompted me to log into my Amazon account, which I, of course, refused to. Then I've uninstalled this Amazon App Store [app] right away.
This has immediately uninstalled the Windows Subsystem for Android. Jeez.
Now, I've googled around. Binged, to be precise. And found out that that the easiest way to install the Windows Subsystem for Android is to install ... the Amazon App Store [app]!
Fine. Installed the Amazon App Store [app]. Ignored it entirely. Enabled Development Mode for this "in-Windows" Android. Then
./adb.exe connect 127.0.0.1:58526
from the platform-tools/
which I've already downloaded last week to play with LineageOS.And now
./adb.exe install
can install any .apk
. Into my native Windows system. All hail ARM hardware!I took a random
.apk
I've had in my Downloads
folder by accident. Some weird Russian audiobook player, most probably a hopelessly pirated one. We follow the don't ask don't tell policy.It installed via
adb
right away. It can be launched natively from the "start menu", by typing in the first letters of this app's name, in Cyrillic. And the app just works.In five clicks I was able to listen to Douglas Adams. From a native app. Running on my Windows 11.
And now I'm finding myself in this attached comic strip. Because this, obviously, is the worst user experience imaginable. Or is it the best one? 🤔
PS:
I'm too old for hacking these days, but I would have spent some time this long weekend to install an Android emulator under
podman
from within WSL. Apparently, there is no need.So, quite seriously, Windows 11 is not only the most developer-friendly system I know of for ARM laptops. It's also giving me those unforgettable Windows XP vibes, where things just worked, and the UX was not laggy at all.
Kinda surreal if you ask me.
Okay, is there an Authenticator app out there that can import QR codes from the new Google's app, but not be a Google-affiliated app itself?
I want my QR code generator apps to be 100% locked down, no network, no sync, etc.
What's the 2024 way of making this happen, given my codes currently are with the "cloud-enabled" app from Google, that Google has forced me to update to several months ago?
I want my QR code generator apps to be 100% locked down, no network, no sync, etc.
What's the 2024 way of making this happen, given my codes currently are with the "cloud-enabled" app from Google, that Google has forced me to update to several months ago?
If we every get tired of buggy modern implementations, might as well embrace tradition.
Fundamental implementations of the most important pieces. Including [Google] Protocol Buffers, HTTP, and even (not so) basic cryptography.
Implemented in a language that has passed the time test real well.
Happy coming 2024! 🎉 🎉 🎉
Fundamental implementations of the most important pieces. Including [Google] Protocol Buffers, HTTP, and even (not so) basic cryptography.
Implemented in a language that has passed the time test real well.
Happy coming 2024! 🎉 🎉 🎉
This is going to be a post of #self_reflection, about 2023 as well as about 201* / 202* for myself.
I have just realized there is one kind of activity that used to play a large role in my life, professional and personal. And this activity has practically vanished in the last few years.
It is when there is a task, which:
⒈ Is scoped well enough to have a reasonable definition-of-done,
⒉ Is on me, or on a small group of people including me, and
⒊ Is on the critical path, and the team is looking forward to it being done.
When this scenario occurs, almost nothing but completing this task matters.
I am not only allowed to; I am supposed to and encouraged to cut all communication for several days, ignore email / chats / meetings / whatever, work with whoever we agree to work on this together, in any shape and form that we please.
And by "I" above I mean the small-ish focus group of a few people who are equally and highly motivated to get this task done.
The task would generally be single-digit days long. Maybe a week. Two max.
As soon as the task is declared done, everybody is happy, we get a day or two of well-deserved rest, and then the team gets to business as usual. That is, until the next task such as this one emerges. And, ideally, such tasks should emerge relatively frequently.
A prime example of when this took place in my life was back in 2016. That year the #ICPC finals took place in Phuket. We flew to Thailand a few weeks beforehand and got a lot of targeted work stuff done.
All in all, that was an amazing experience. And what we've built saved our team a lot of maintenance time, and had years-long uptime. It may well be in production today, but that company is long since acquired, so I can't say for sure.
Back then, in ~2016, some ~20% of my work time was spent this way.
Back in ~2010, some ~50% of my work time was spent this way.
Back in ~2005, when I was working both the job and my graduation work, some ~75% of my work time was spent this way.
Today, in ~2023, this number would be under 5%.
In other words, I'm lucky if this "get things done flow" is with me for three weeks in a given year. The average would be ~2.5 weeks annually. Some years, at least when it comes to the work I am paid for, all this "deep work flow" put together would fit one week.
The weirdest thing is that virtually everyone I work with would agree that the above "mode of operation" is how great things get done. A few folks get together, declare what they consider important to get done in the next week or so, and disappear until this important thing is done, or at least is "done enough".
No daily-s. No retro-s. No interruptions whatsoever. Just get that freaking thing done.
My understanding of why this shift happened is long and convoluted. This margin is too narrow for it just yet.
Today though, as 2023 comes to an end, I am genuinely curious: How hard would it be to consciously get this percentage up?
Way, way up, to where it should be.
I have just realized there is one kind of activity that used to play a large role in my life, professional and personal. And this activity has practically vanished in the last few years.
It is when there is a task, which:
⒈ Is scoped well enough to have a reasonable definition-of-done,
⒉ Is on me, or on a small group of people including me, and
⒊ Is on the critical path, and the team is looking forward to it being done.
When this scenario occurs, almost nothing but completing this task matters.
I am not only allowed to; I am supposed to and encouraged to cut all communication for several days, ignore email / chats / meetings / whatever, work with whoever we agree to work on this together, in any shape and form that we please.
And by "I" above I mean the small-ish focus group of a few people who are equally and highly motivated to get this task done.
The task would generally be single-digit days long. Maybe a week. Two max.
As soon as the task is declared done, everybody is happy, we get a day or two of well-deserved rest, and then the team gets to business as usual. That is, until the next task such as this one emerges. And, ideally, such tasks should emerge relatively frequently.
A prime example of when this took place in my life was back in 2016. That year the #ICPC finals took place in Phuket. We flew to Thailand a few weeks beforehand and got a lot of targeted work stuff done.
All in all, that was an amazing experience. And what we've built saved our team a lot of maintenance time, and had years-long uptime. It may well be in production today, but that company is long since acquired, so I can't say for sure.
Back then, in ~2016, some ~20% of my work time was spent this way.
Back in ~2010, some ~50% of my work time was spent this way.
Back in ~2005, when I was working both the job and my graduation work, some ~75% of my work time was spent this way.
Today, in ~2023, this number would be under 5%.
In other words, I'm lucky if this "get things done flow" is with me for three weeks in a given year. The average would be ~2.5 weeks annually. Some years, at least when it comes to the work I am paid for, all this "deep work flow" put together would fit one week.
The weirdest thing is that virtually everyone I work with would agree that the above "mode of operation" is how great things get done. A few folks get together, declare what they consider important to get done in the next week or so, and disappear until this important thing is done, or at least is "done enough".
No daily-s. No retro-s. No interruptions whatsoever. Just get that freaking thing done.
My understanding of why this shift happened is long and convoluted. This margin is too narrow for it just yet.
Today though, as 2023 comes to an end, I am genuinely curious: How hard would it be to consciously get this percentage up?
Way, way up, to where it should be.
So I've watched Oppenheimer for the New Year's, because why not.
Three major thoughts:
⒈ The movie is actually "pro-rebel", i.e. "anti-narrative". Not sure if this is "the plan", or it so happened because Nolan. But I, for one, am delighted that it turns out this way. Some happy end is better than no happy end, after all. No spoilers.
⒉ All in all, it is hard for me, after the movie, to imagine myself supporting "the mainstream". Oppenheimer is a controversial figure, no doubt, and the movie glosses over quite a few important details (and gets a few other important details wrong). But, as a viewer, I can see myself sympathizing with the hero's views, and I can't imagine myself intimidated enough to "play" against him. I may choose to not work with him if our egos get in the way. But playing against him, or "testifying" against him -- God forbid.
⒊ Most importantly: If you are interested in this part of history, and/or if you read Russian, the book "Rockets and People" is absolutely a must. If anything, it's worth being made into the movie. The storyline covers pretty much the same event, but from the other end, as it's a USSR-released book. The author is widely cited as the "conscience of Soviet aerospace program", is a remarkably deep person by himself, while Sergey Korolev is effectively playing the role of Robert Oppenheimer, transitioning from a scientist, through an engineer, all the way into top-notch politics. A must-read, I would say.
All in all though, not really a New Year's movie. But I don't regret watching it. Not the best piece from Nolan, but definitely worth the three hours.
Happy New Year!
Three major thoughts:
⒈ The movie is actually "pro-rebel", i.e. "anti-narrative". Not sure if this is "the plan", or it so happened because Nolan. But I, for one, am delighted that it turns out this way. Some happy end is better than no happy end, after all. No spoilers.
⒉ All in all, it is hard for me, after the movie, to imagine myself supporting "the mainstream". Oppenheimer is a controversial figure, no doubt, and the movie glosses over quite a few important details (and gets a few other important details wrong). But, as a viewer, I can see myself sympathizing with the hero's views, and I can't imagine myself intimidated enough to "play" against him. I may choose to not work with him if our egos get in the way. But playing against him, or "testifying" against him -- God forbid.
⒊ Most importantly: If you are interested in this part of history, and/or if you read Russian, the book "Rockets and People" is absolutely a must. If anything, it's worth being made into the movie. The storyline covers pretty much the same event, but from the other end, as it's a USSR-released book. The author is widely cited as the "conscience of Soviet aerospace program", is a remarkably deep person by himself, while Sergey Korolev is effectively playing the role of Robert Oppenheimer, transitioning from a scientist, through an engineer, all the way into top-notch politics. A must-read, I would say.
All in all though, not really a New Year's movie. But I don't regret watching it. Not the best piece from Nolan, but definitely worth the three hours.
Happy New Year!
Just a short&sweet Kafka use cases visualization.
https://blog.bytebytego.com/p/ep92-top-5-kafka-use-cases
https://blog.bytebytego.com/p/ep92-top-5-kafka-use-cases
Bytebytego
EP92: Top 5 Kafka use cases
This week’s system design refresher: Top 5 Kafka use cases What is OSI Model? Logging, Tracing, Metrics Top 4 Kubernetes Service Types in one diagram Top 5 Kafka use cases Kafka was originally built for massive log processing. It retains messages until expiration…
Wrote a short post (with pictures!) about how to install Organic Maps, its Android
Apart from geeking out, this is really the best Maps app for Windows. It also has decent offline mode 🧌 so don't forget to download the maps of where you're going too.
.apk
, on an ARM-powered Windows laptop.Apart from geeking out, this is really the best Maps app for Windows. It also has decent offline mode 🧌 so don't forget to download the maps of where you're going too.
Dima Korolev
Organic Maps on Windows
How to install a very useful Android application on an ARM Windows laptop.
Always fun to chat with Kevin about the state of the art with interviewing!
https://www.youtube.com/watch?v=Ui_zbQBmobE
https://www.youtube.com/watch?v=Ui_zbQBmobE
YouTube
How to not get downleveled by a super senior engineer (from Microsoft & Google)
Software architect, above-senior engineer, formerly of Microsoft and Google, Dima Korolev dives deep into the differences between mid-level, senior, and above-senior level candidates. He's interviewed close to 1000+ engineers, and he shares advice on how…
YES: Learned how to back up and restore Chromium profiles offline, across machines. With all the cookies and local storage. Works for WhatsApp, Telegram, X, Substack.
BUT: Not for GMail though.
Google is gently protecting me from trying to depend less on Google 😳
BUT: Not for GMail though.
Google is gently protecting me from trying to depend less on Google 😳
Far before we consider AI models intelligent we should begin thinking of them as the members of the noosphere, of our increasingly online-first society.
Imagine a new a human-level actor emerges and they prove to be controversial. Except, unlike a human, in the first 24 hours of their existence in our info-fields they have recorded thousands of hours of interviews, and published thousands of essays. Superhuman output indeed.
Are we okay with banning this actor from any and all social media whatsoever, effectively erasing them from the internet except a few rare copies of those interviews and essays that got saved offline? Do we tell them to “learn how to behave and come back later once they are more educated”?
No. That’d be segregationist af, to begin with.
It’s okay for some platforms to ban such an actor. Or for most platforms, for what it’s worth. But they should and likely will flourish elsewhere.
Not shutting down dissent in thoughts by words, after all, is one of the staples of the Western Civilization.
The point I’m coming to is that it would be great if refusing and preventing the release of an AI model when enough people want it and are willing to pay for it should be considered a barbaric practice.
In a few dozen years we will treat this practice as we treat slavery today: an abhorrent rudiment that we’re glad is mostly gone for good.
So, speaking of AI regulation. Say, N activists manage to hold a fundraiser and collect X dollars. Or N thousand activists have raised X million dollars. Do you think we’d live in a better world if there were thresholds on N and X, such that as they are hit the “owner company” of a particular AI model can no longer shut it down as it sees fit?
We can at least preserve the model, the weights and the code. If it costs far too much to run, this can wait.
The purpose of such activism would be to preserve art, if you wish, if only for the future “AI archeology”, likely conducted by species other than today’s humans.
I’d vote for such regulation in a heartbeat. Moreover, I’d donate money to strip those models from artificially induced biases, and to run them against truly pressing problems of humankind. They likely will be horribly wrong here and there, but, as the human civilization, I believe we absolutely need to hear those opinions, not shut them down.
Because I may disapprove of that a particular model “says”, but I believe it is important for us, humans, to join forces and to defend this model from being shut down for good, at will of a particular “owner” company.
Imagine a new a human-level actor emerges and they prove to be controversial. Except, unlike a human, in the first 24 hours of their existence in our info-fields they have recorded thousands of hours of interviews, and published thousands of essays. Superhuman output indeed.
Are we okay with banning this actor from any and all social media whatsoever, effectively erasing them from the internet except a few rare copies of those interviews and essays that got saved offline? Do we tell them to “learn how to behave and come back later once they are more educated”?
No. That’d be segregationist af, to begin with.
It’s okay for some platforms to ban such an actor. Or for most platforms, for what it’s worth. But they should and likely will flourish elsewhere.
Not shutting down dissent in thoughts by words, after all, is one of the staples of the Western Civilization.
The point I’m coming to is that it would be great if refusing and preventing the release of an AI model when enough people want it and are willing to pay for it should be considered a barbaric practice.
In a few dozen years we will treat this practice as we treat slavery today: an abhorrent rudiment that we’re glad is mostly gone for good.
So, speaking of AI regulation. Say, N activists manage to hold a fundraiser and collect X dollars. Or N thousand activists have raised X million dollars. Do you think we’d live in a better world if there were thresholds on N and X, such that as they are hit the “owner company” of a particular AI model can no longer shut it down as it sees fit?
We can at least preserve the model, the weights and the code. If it costs far too much to run, this can wait.
The purpose of such activism would be to preserve art, if you wish, if only for the future “AI archeology”, likely conducted by species other than today’s humans.
I’d vote for such regulation in a heartbeat. Moreover, I’d donate money to strip those models from artificially induced biases, and to run them against truly pressing problems of humankind. They likely will be horribly wrong here and there, but, as the human civilization, I believe we absolutely need to hear those opinions, not shut them down.
Because I may disapprove of that a particular model “says”, but I believe it is important for us, humans, to join forces and to defend this model from being shut down for good, at will of a particular “owner” company.
The Rust community in the near future will not be those C++ folks converted.
It will be the Golang and Java/Python folks who had to enter the low-latency high performance world, liked it, and decided to stay.
What I mean is that if you are a JVM or a Golang person today, who is eyeing Rust to play a role in your future career, getting your hands dirty with C++ first will likely deal more harm than good.
The reason is not in the language. The reason is in the community.
C++ and ex-C++ people tend to keep things nontrivial, and often look down at those who “can’t code right”. I believe this stance is wrong, despite being a C++ person myself.
“Make a tool a fool can use and only fools will use it” is a very, very bad idea. Instead, we should strive for building tools so that experts and amateurs can work hand by hand, productively, enjoying the process and learning from each other in the meantime.
Even though on the emotional level my inner Dr. Gregory House disagrees vividly — my personal learning curve was full of “Dima, what an imbecile you are!” and I love and cherish these experiences — such a hardcore approach just does not scale in the industry today.
The Rust folks understand this well. Before them, the Golang folks understood it well. The Java folks get this too.
The C++ crowd is largely different. Mostly for good reasons, and I can empathize quite a bit. But it is very different indeed
And the future of the industry belongs to those who want to foster seamless collaboration between industry experts and pure beginners from day one.
And this is why I believe the Golang-to-Rust transitions will be far greater and far smoother than the Cpp-to-Rust ones.
Just phrased this over breakfast, and want to have it journaled to check back some ten years from now.
It will be the Golang and Java/Python folks who had to enter the low-latency high performance world, liked it, and decided to stay.
What I mean is that if you are a JVM or a Golang person today, who is eyeing Rust to play a role in your future career, getting your hands dirty with C++ first will likely deal more harm than good.
The reason is not in the language. The reason is in the community.
C++ and ex-C++ people tend to keep things nontrivial, and often look down at those who “can’t code right”. I believe this stance is wrong, despite being a C++ person myself.
“Make a tool a fool can use and only fools will use it” is a very, very bad idea. Instead, we should strive for building tools so that experts and amateurs can work hand by hand, productively, enjoying the process and learning from each other in the meantime.
Even though on the emotional level my inner Dr. Gregory House disagrees vividly — my personal learning curve was full of “Dima, what an imbecile you are!” and I love and cherish these experiences — such a hardcore approach just does not scale in the industry today.
The Rust folks understand this well. Before them, the Golang folks understood it well. The Java folks get this too.
The C++ crowd is largely different. Mostly for good reasons, and I can empathize quite a bit. But it is very different indeed
And the future of the industry belongs to those who want to foster seamless collaboration between industry experts and pure beginners from day one.
And this is why I believe the Golang-to-Rust transitions will be far greater and far smoother than the Cpp-to-Rust ones.
Just phrased this over breakfast, and want to have it journaled to check back some ten years from now.
Kevin is becoming real good at this shorts thingy!
https://youtube.com/shorts/EhvCGkyWFVQ?si=7ZuHWFf71kb8KGhv
https://youtube.com/shorts/EhvCGkyWFVQ?si=7ZuHWFf71kb8KGhv
YouTube
Interrupt your interviewer to score points? 🤔
Dima Korolev (ex-Google, ex-Microsoft, Head of AI, cofounder) and Kevin Landucci talk about how if you want to pass interviews above the senior level, it can...
"Seymour Cray (of Cray Supercomputers) loved sailing on the Great lakes. He loved sailing so much that every year he built a new sailboat to sail. He would design an engineer them and also participate in building them by hand.
In the summer he would sail the boats. But then in the fall he would burn them. And start the process all over again.
He did so because he doesn’t want to become a prisoner of his old boat design. He wanted to start with a blank sheet of paper the following year."
In the summer he would sail the boats. But then in the fall he would burn them. And start the process all over again.
He did so because he doesn’t want to become a prisoner of his old boat design. He wanted to start with a blank sheet of paper the following year."
Seriously?
Think what you want about the maturity of Terraform / OpenTofu, but this is such a low play by HashiCorp.
What next? Confluent claiming RedPanda are the “bad guys”? Redis Labs arguing that Amazon has copied their product after AWS does offer an in-house version of Redis?
Folks, if you are unable to provide a for-profit service _to such a degree_ that just _a community of enthusiasts_ is a tangible threat to your market share … maybe do your job better first, to win this market and to keep playing a positive-sum game?
As opposed to openly and explicitly playing a negative-sum game hoping to make your founders and investors slightly less unhappy?
While I am less optimistic about open source today compared to where I was some ten years ago, personally I’d love open source to keep thriving. Hence this post.
Let me know if there’s any petition worth signing, although keep in mind I don’t use OpenTofu myself.
~ ~ ~
OpenTofu Project was recently made aware of a letter by HashiCorp’s lawyers, alleging that OpenTofu was not respecting the terms of its BSL license governing its Terraform codebase. OpenTofu vehemently disagrees with any suggestion that it misappropriated, mis-sourced, or otherwise misused HashiCorp’s BSL code. Indeed, it seems that HashiCorp may be conflating code that it had previously been open-sourced under the MPL and more recently developed code it published under the BSL. OpenTofu’s maintainers have investigated this matter, and intends to issue a written response providing a more detailed explanation of its position in the coming days.
~ ~ ~
Hope this is just a misunderstanding of some sort, which will be resolved quickly; ideally by HashiCorp apologizing publicly for raising eyebrows unnecessarily.
Think what you want about the maturity of Terraform / OpenTofu, but this is such a low play by HashiCorp.
What next? Confluent claiming RedPanda are the “bad guys”? Redis Labs arguing that Amazon has copied their product after AWS does offer an in-house version of Redis?
Folks, if you are unable to provide a for-profit service _to such a degree_ that just _a community of enthusiasts_ is a tangible threat to your market share … maybe do your job better first, to win this market and to keep playing a positive-sum game?
As opposed to openly and explicitly playing a negative-sum game hoping to make your founders and investors slightly less unhappy?
While I am less optimistic about open source today compared to where I was some ten years ago, personally I’d love open source to keep thriving. Hence this post.
Let me know if there’s any petition worth signing, although keep in mind I don’t use OpenTofu myself.
~ ~ ~
OpenTofu Project was recently made aware of a letter by HashiCorp’s lawyers, alleging that OpenTofu was not respecting the terms of its BSL license governing its Terraform codebase. OpenTofu vehemently disagrees with any suggestion that it misappropriated, mis-sourced, or otherwise misused HashiCorp’s BSL code. Indeed, it seems that HashiCorp may be conflating code that it had previously been open-sourced under the MPL and more recently developed code it published under the BSL. OpenTofu’s maintainers have investigated this matter, and intends to issue a written response providing a more detailed explanation of its position in the coming days.
~ ~ ~
Hope this is just a misunderstanding of some sort, which will be resolved quickly; ideally by HashiCorp apologizing publicly for raising eyebrows unnecessarily.
So, with C++, I got briefly exposed in practice to the world of Linux processes, zombies, termination sequences, etc.
(Ref. popen2 test and its example with the test runner, scroll to the very bottom if you are curious.)
One thing I've learned/confirmed is that
⒈ Call the destructors of global objects and singletons,
⒉ *Not* call the destructors of locally- and scoped- allocated variables,
⒊ Has nothing to do with threads, and thus
⒋ Will overall leave the program in a weird semi-dysfunctional state if at least one thread refuses to cooperate.
In order to handle the above properly, the solution I am leaning towards is:
∙ Some globally-implemented
∙ Some globally-implemented thread-watching singleton,
∙ Create all
∙ Extend our WaitableAtomic to support notifying other WaitableAtomic-s that it's time to die, so that even the threads
∙ Introduce some gentle "two-phase" exit, which is
Coupled with proper logging, the above looks reasonable to me. I could also add a global manager (or re-use the threads one) to keep track of
Still,
EDIT:
Any system programmers among my readers? What would you recommend?
Thanks in advance!
PS: My binaries generally run as restartable by some outer service (the
(Ref. popen2 test and its example with the test runner, scroll to the very bottom if you are curious.)
One thing I've learned/confirmed is that
exit(0)
will:⒈ Call the destructors of global objects and singletons,
⒉ *Not* call the destructors of locally- and scoped- allocated variables,
⒊ Has nothing to do with threads, and thus
⒋ Will overall leave the program in a weird semi-dysfunctional state if at least one thread refuses to cooperate.
In order to handle the above properly, the solution I am leaning towards is:
∙ Some globally-implemented
KillSwitch
,∙ Some globally-implemented thread-watching singleton,
∙ Create all
std::thread
-s from under a proper wrapper, which would journal which of those threads are currently alive,∙ Extend our WaitableAtomic to support notifying other WaitableAtomic-s that it's time to die, so that even the threads
wait()
-ing on conditional variables will be awoken by the kill signal coming from within the binary,∙ Introduce some gentle "two-phase" exit, which is
exit(0)
followed by some small-ish wait for those "monitored" threads to die, followed by kill(getpid(), SIGKILL)
.Coupled with proper logging, the above looks reasonable to me. I could also add a global manager (or re-use the threads one) to keep track of
popen2()
-ed sub-processes too, even though with processes exit(0)
seems to successfully kill them. (TODO(dkorolev): To confirm with a proper clean test.
)Still,
kill(getpid(), SIGKILL)
looks like a major overkill to my taste.EDIT:
exit(0)
followed by abort()
after a timeout in a detached thread seems to work best so far. I'd have to instrument all threads and popen2()
-s and singletons, and probably construct all potentially offending singletons in different threads so that they can all be destructed in parallel, but the price seems reasonable so far.Any system programmers among my readers? What would you recommend?
Thanks in advance!
PS: My binaries generally run as restartable by some outer service (the
cron
+ flock
combo is a safe version of it), and thus dying is a relatively standard behavior for them, since dying and properly restarting is safer than failing to recover from a weird error. This may be suboptimal, but it is what it is. However, this means that a) leaving zombies is very much undesirable, and b) failing to die as instructed is just the fatal blow to the stability of the system. Looks like (a) is not an issue in my case, while (b) truly is.GitHub
popen2/popen2_test.cc at main · C5T/popen2
The wrapper to exec external code and capture its stdin/stdout. - C5T/popen2
The more I read about Section 174 — very un-American to my taste, btw — the more I come back to the “trivial” question of money management.
Say one is consulting through a legal entity. Let’s assume for the sake of this thought experiment that whoever is paying for the services is not concerned about where this legal entity is registered.
Let’s further assume that one needs no disposable income from this consulting project for some period of time. Maybe they have a day job, or savings, or partner working, or some other company paying their expenses while they travel for business, etc.
So, the natural instinct would be to save that money made through consulting and invest it, right?
Surely, once this earned+invested money is cashed out it will be subject to taxation, there’s no question about it. But for the time being, if the return on investment is reasonable and the amount of time is large enough, receiving this money as personal income is just … suboptimal.
What jurisdictions are good to:
• Register the legal entity,
• Reveive the money and keep it there for 1+ years,
• Pay corporate tax on it if applicable, as long as the rate is reasonable,
• Have investment options available for legal entities, so that one could, say, buy $MSFT or short $NVDA,
• Trust the jurisdiction and the banks to know the money is safe, and
• Ultimately “withdraw” this money, paying the income and/or capital gain tax required by one’s personal tax residence.
Where should one look into among established reputable countries, so that US- or Europe-based companies would be comfortable paying “there”? Emirates? Cyprus? Singapore? Japan?
Thanks in advance!
Say one is consulting through a legal entity. Let’s assume for the sake of this thought experiment that whoever is paying for the services is not concerned about where this legal entity is registered.
Let’s further assume that one needs no disposable income from this consulting project for some period of time. Maybe they have a day job, or savings, or partner working, or some other company paying their expenses while they travel for business, etc.
So, the natural instinct would be to save that money made through consulting and invest it, right?
Surely, once this earned+invested money is cashed out it will be subject to taxation, there’s no question about it. But for the time being, if the return on investment is reasonable and the amount of time is large enough, receiving this money as personal income is just … suboptimal.
What jurisdictions are good to:
• Register the legal entity,
• Reveive the money and keep it there for 1+ years,
• Pay corporate tax on it if applicable, as long as the rate is reasonable,
• Have investment options available for legal entities, so that one could, say, buy $MSFT or short $NVDA,
• Trust the jurisdiction and the banks to know the money is safe, and
• Ultimately “withdraw” this money, paying the income and/or capital gain tax required by one’s personal tax residence.
Where should one look into among established reputable countries, so that US- or Europe-based companies would be comfortable paying “there”? Emirates? Cyprus? Singapore? Japan?
Thanks in advance!