Oh My Task! – Telegram
Oh My Task!
245 subscribers
6 photos
10 links
Here I share my knowledge and interests with the geeks who at least once yelled "OH MY F… TASK!"

You’ll read about OS, concurrency, multi-processing and stuff in this channel.

Reach me at @ShahriarShariati
Download Telegram
Channel created
Alright geeks. Guess I should start posting here after almost 2 years of occupying the @ohmytask

You know, focusing is difficult these days. You have so many things to think about. And the growth of technology… I mean how the hell we could reach that much advanced AI tools for less than 2 years?!

So yeah, we can’t focus like our ancestors. Neither do our computers. They can’t focus too. Or better to say they should not focus on one thing. We don’t need them to focus. We need them to overthink many things. We want them to get stuck in the loops. Loops like the web servers that help you see this message right after I click the send button.

Let’s talk about these tiny hardware-beings that can’t focus. Here in this channel.
👍8
I always have a respect for the aged geeks who have been growing with the technology and felt the history instead of reading it. One of them is David Beazley. He was one of the developers who used first versions of Python (<=1.0) in big projects and it’s cool to see these guys seen all the change history of these tools and programming languages.

Follow him on Youtube and watch his lectures about multi-threading and asyncio.

Here he’s teaching you how to build your async:
https://youtu.be/Y4Gt3Xjd7G8?si=A4GrpDoqQPZ8Q8G5

@OhMyTask
7👍5🖕1
Will get rid of GIL?

Of course I’m exited for using the power of a Python without the annoying GIL.

But to be honest, I read their official announcement about that and it includes a lots of "if"s :)
They are really concerned about breaking changes and backward compatibility. They should be actually.
They even mentioned a couple of times that "We’ll bring back GIL if it causes problems" [1].

So let’s not be geeky emotional about it. And remember, Developers asked many times from the man who invented Python: Will we have a Python without the GIL? And the answer is "I’m OK. Do it if you can do it without any breaking changes[2].
From my sight, he got a point. They really don’t want to repeat Python 2 -> 3 challenges. They avoid increasing complexity. And more importantly, they don’t seem to be really convinced of reasons behind removing GIL.

So let’s use tools right. Python is powerful? Right. Our code base is on it and this GIL is really annoying? Correct. But these changes won’t happen in one night and even when they happen, might not be like our expectations.

I prefer to use another programming languages when I really concerned about using the power of my CPU. At least for the next 5 years :)

@OhMyTask
👍8
Be careful. Your load balancer might make the workers jealous.

@OhMyTask
😁6
Are workers jealous of each other?

Assume the point of life of each worker, is the highest amount of assigned tasks. We’re running a distributed processing system. The main process is gonna distribute the incoming tasks to its forked process (workers). How to divide fairly? You know the tasks are indivisible objects. We cannot trim a function and say: Hey worker 1, do up to line 12. Hey worker 2, do the rest.

What if the workers envy each other? For example, worker 1 is free at this time and really needs a task to do. But you give a task to worker 2 instead. Which might be full of tasks already. They may envy each other.

Is there always an envy-free approach? Unfortunately not. The world doesn't work like that. Or maybe from the point of view. So how can we implement some task allocation strategy for our workers to not envy each other?

Let's do some simplification. We can't be 100% envy-free right? Ok. Let's say a worker is now jealous of some other workers. And the jealousy is gone by giving only one task to it. We do it. Give one task to the jealous worker and boom! Now no one will envy each other. It’s called envy-free up to one good. Or shortly EF1. Which is a relaxation method for envy-free item allocation. One of the main fields in computational social choice.

The Round-robin algorithm is one of the best EF1 item allocation algorithms. It assigns the incoming tasks to workers sequentially. For example, if we have 4 workers (W) and 5 tasks (T). It assigns:
T1 -> W1
T2 -> W2
T3 -> W3
T4 -> W4 (End of workers)
T5 -> W1 (Start at first)


It’s proved that workers do not envy each other if, at each round, we give one task to the worker who has the most free computational resource (or the most desire for a new task).

So next time you see the Round-robin method in broker exchange, scheduling, load balancing, etc.. Remember the logic behind it. It tries to be a fair parent process to its forked children.

@OhMyTask
🔥3👍2🥴1🆒1
Let Ants do the job @OhMyTask
👍4
Decentralized Brain of Nature

What is your first reaction when you see an ant or a group of them? Scream? Get mad? Grap something and try to kill them?

OK. Chill out for one minute. Let's observe. Imagine you see a group of ants (more often) and they're living their life, stealing your tiny pieces of food and going back to their colony.
Have you ever wondered how they're moving in a specific pattern without chaos? Are they talking to each other and yelling: Hey ant-186, look where ant-240 is going and follow him? Are they sending wireless messages to each other?

Nature knows its way. The group of ants has a decentralized brain or more scientific Swarm intelligence. When they are moving, they emit chemicals called Pheromone. These pheromones help ants find the path to a food source and also return to the nest in an efficient manner.
The pheromone has a lifetime and the more time passes, the smell of it gets weaker. So the ants know this pheromone is new or old. The more amount of pheromone on a route, the stronger smell, and probably the more efficient and acceptable path to use.

What's the point here? Ok. Let's see what challenges we have in our systems. Imagine we are in a huge and complex internet network with lots of nodes, lots of connections, lots of routers, etc.
We have groups of packets from node A to node B. There are a couple of ways to reach the node B. In a chaotic strongly connected network. How do you efficiently find the best path to Node B?

Or imagine there has been a fire accident and you're sending a couple of rescue drones to find injured people. The fire is getting worse. Drones are inside the building. How do you manage these drones to don't get damaged and most importantly, find the people inside the building as fast as they can?

Two above challenges and many challenges like those couldn't be solved by a centralized management system. They could but it's not that efficient and reliable. So here the algorithms of nature would help us. Swarm intelligence algorithms such as ACO (Ant Colony Optimization) we learned earlier could save lots of lives.

The deeper you look at the phenomena, the more you avoid erasing or killing them. Just you learn from the behavior.

@OhMyTask
👍4🔥21
Suppose you're looking for a "complete enough" course for async-await programming on Python. Who's better than an active contributor of Python to teach you?

Take a look at this amazing ~6 hours course made by Łukasz Langa (Python core developer)

https://youtube.com/playlist?list=PLhNSoGM2ik6SIkVGXWBwerucXjgP1rHmB&si=eyhr590l6I9DlIZi

@OhMyTask
👍13
What I mean by the handler of this channel @OhMyTask
😁10
The Creation of App
@OhMyTask