Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.

Commit 124cdbf

Browse files
committed
vault backup: 2024-04-07 14:08:09
1 parent fde1234 commit 124cdbf

File tree

17 files changed

+148
-21
lines changed

17 files changed

+148
-21
lines changed

content/education/omscs/cs-6200.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
tags:
3+
- thoughts
4+
aliases:
5+
- gios
6+
---
7+
My first class I took at Georgia Tech's OMSCS program was cs-6200, or Graduate Introduction to Operating Systems (**GIOS**). I took it in **Spring 2024**. This is my first formal CS class, ever. I took a couple in college but they were mostly fluff and designed around numerical applications of code. I took it alongside [[cs-7674|ml4t]].
8+
9+
I loved the class. It's probably my favorite class I've taken in anything, ever.
10+
11+
In GIOS, the cool thing is that the projects are open-ended. All you have to do is pass a test suite they provided. For Project 1, I did it strictly by the book. For Project 3, I did something very weird and zany to the point where the Autograder actually got confused by my project, leading to a manual grading required (apologies to my TA).
12+
### Notes I wrote because of this class
13+
14+
[[sending-fds-through-uds]]: I utilized this in Project 3.
15+
[[fcntl-atomic-locks]]: I utilized this in Project 3, though I had to scrap my usage of it because I discovered it doesn't work as expected.
16+
[[macos-native-docker]]: The class environment is on an Ubuntu 20.04 environment and x86, I needed to run a docker image to perfectly replicate our testing environment (provided by the class) to make sure I wasn't dealing with quirks. I use a M1 Pro Macbook 14 that I absolutely adore, and didn't want to deal with a Cloud VM to develop.

content/education/omscs/cs-7674.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
tags:
3+
- thoughts
4+
aliases:
5+
- ml4t
6+
---
7+
My second class at OMSCS was cs-7674, Machine Learning for Trading (**ML4T**). I thought it was... alright? It's mostly just Python stuff, of which I'm very familiar with. I took it alongside [[cs-6200|gios]]. It's kind of like an introduction into data science techniques with a focus on ML. Now I'm not an ML person at all, my undergraduate background is in Economics and Math, but ML is just statistical models.
8+
9+
I spent maybe 10 hours per week on the class.
10+

content/education/omscs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Notes about all the classes I took at OMSCS, with a mini review and any thoughts I had about them.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
tags:
3+
- thoughts
4+
title: Regret and ADHD
5+
description: I got diagnosed with ADHD when I was 21 years old. I was illuminating, and extremely frustrating.
6+
---
7+
I've always been a person who kinda, "does their own thing". You could call it selfishness. You could call it eccentricity. The truth is probably somewhere in the middle.
8+
9+
I learned it's called, "my dopamine regulators are just a teensy bit fucked up".
10+
11+
I've never been a good student. According to my GPA, at least. In high school, I was constantly engaged, pretty funny, and all my teachers would always tell me I was one of their favorite students. But I seldom did homework, I skipped class all the time because I was bored, and my GPA was *low*. Like, in the low 3.0s *weighted*, which is nuts considering I took many Honors and AP classes. I did well on the standardized tests, which were my saving grace, but I never really cared to study for them. And why would I? I got 98 percentile scores. I ended up getting into an "elite" college which had a test-optional policy.
12+
13+
Had I studied, I would've gotten 99 percentile scores. And that's the damn problem.
14+
15+
In college, I decided to reinvent myself. I would throw myself into the library for hours each day, refusing to do homework in my room. I tried every strategy I could, using pomodoro, forcing myself to take hand-written notes. My grades rapidly improved in college.
16+
17+
But my grades were not improving because I had become a better student, it was because the distribution of my homework had changed. I didn't have busy work. At the time, I prided myself on my dedication and hustle. I knew that if I put my mind to anything, I could do anything.
18+
19+
But I was burnt out. So, so heavily burnt out. While I saw my friends take notes that would only take them a couple hours, it took me double that. And that's not to say that the actual *process* of consuming information and writing notes was difficult, but hunkering down to take the notes was the actual problem. I would get distracted.
20+
21+
At the age of 21, I got diagnosed with ADHD from a psychiatrist. She remarked to me that "it's incredible that I got so far with my level of hyperactivity and inattentiveness". I think she was trying to make me feel better, but in all honesty, it made me feel like dogshit.
22+
23+
When I was a child, I had been misdiagnosed with ASD, which then corrected itself after some speech therapy. Turns out, they had identified there really was something fucky-wucky with my brain, but the wrong causality was attributed to it. I'm not the only one, nor will I be the first.
24+
25+
Sorry for all the swearing. You might be able to tell, but this whole topic makes me feel pretty emotional.
26+
27+
I started taking Vyvanse at the start of my senior fall semester, which cost me 50 bucks a month. I had to quit it later that semester since I had poor cardiovascular health that was being exacerbated by the drug, but for the first time in my entire life, I had *focus*. I could do things without expending mental effort. I wrote my entire thesis while on this amphetamines.
28+
29+
Like most brain disorders, ADHD is not well-understood. Anyone claiming they definitively *know* how ADHD works is an idiot or a grifter. The general consensus seems to be that people with ADHD have messed-up dopamine receptors. That is, their risk-reward functions are messed up. While I can logically conceptualize the advantages of risk-reward, my ADHD brain doesn't agree with my logical processing. That was the source of my exhaustion, I was waging a war with my own brain, convincing it to believe the own things I reasoned myself to do. Amphetamines solve this by reversing the dopamine transmission inside the brain, enabling people with this so-called "dopamine deficiency" to have the same *feelings* of reasoning that other people do. It's no longer a war, my body agrees with (or defers? to) my logic.
30+
31+
What could I have been if I were to be properly medicated? Could I be a quant making 500k? Whatever, I'm a software engineer in America, I make so much money relative to my peers and the entire world that complaining I'm not making quadruple that deserves a punch in the face.
32+
33+
Would I have done a better job developing meaningful relationships with other people instead of dropping in and out of their lives, treating them like our relationships are ephemeral? This is the thing that kills me the most. My whole life, I've treated relationships like they should *always* be there. I've had friends I haven't talked to in months, and then expect them to be the exact same when I return. My logic being, "I'm gonna treat you the same way I always treated you, why would you change?" This is not how people work. I've lost many relationships by treating people like this.
34+
35+
And those aren't things I can get back. No one cares or wants to listen to "sorry I treated you terribly, my dopamine receptors suckkkk bro".
36+
37+
I feel embarrassed talking about this, in all honesty. I don't want to be the person who blames my problems on something outside of me. But what exactly *am* I supposed to do? It's disingenuous to say that my literal brain chemicals aren't responsible, at least partially, for my behavior. The way I try to rationalize it is that the ADHD provides an explanation, but it doesn't really provide an excuse. I'm ultimately responsible for my actions, regardless for why they happened. It doesn't make me feel good to reach this conclusion, but it's the only one that doesn't run contrary to my own values.
38+
39+
I'm luckier than most. I got diagnosed when I was 21. I was high-performing *before* my diagnosis, and high-performing *after*. If you read this piece as "a smart, accomplished person complaining he's in the 90th percentile not the 95 percentile." you would be right. Comparison is the thief of joy. But in this case, the comparison is to myself.
40+
41+
Amphetamines aren't considered addictive in the chemical sense. However, people without ADHD get psychologically hooked onto them because they unlock a higher level of cognition, and they find that they don't acknowledge themselves outside their meds. Their better version is who they are. I can relate and understand. But to me, I don't consider myself on my meds to be *a better version of myself*, I consider them to be *who I am meant to be*.
42+
43+
So what can I do? I can keep moving forward. I can try and not feel regret. But it's damn hard. For the formative years of my life, I was working with a penalty. I accomplished so much, but I could've accomplished more. Instead of beating myself up every single night and feeling intense self-loathing, wondering why I simply can't do things the way other people do, I could've had something else to blame.
44+
45+
I can't take back my actions. All I can do is improve. I hope someday I will no longer feel regret. I think it will happen, some day in the future. But for now, all I can do is live with it.

content/media/books/world-war-z.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
tags:
3+
- thoughts
4+
---
5+
I watched the movie, World War Z, and hated it. Then I read the book, World War Z, and I loved it.

content/sports/nba/advanced-stats.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ tags:
33
- notes
44
---
55
- EPM
6-
- Raptor
6+
- RAPTOR
77
- BPM
88
- RAPM
9-
-
9+
- DARKO

content/sports/nba/basketball-makes-me-really-emotional.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
tags:
33
- thoughts
4+
title: Basketball makes me really emotional
5+
description: My attempt to articulate why Basketball as a sport speaks deeply to me.
46
---
57
I saw this tweet the other day.
68

content/tags/notes.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
Notes about various topics, both for my book-keeping and to cite any sources or articles I found interesting. I wouldn't consider these comprehensive or pointing in any one direction or opinions, just a dump of bullet points.
1+
Notes about various topics. I wouldn't consider these comprehensive or pointing in any one direction or opinions, just a dump of bullet points and citations.
2+
3+
These are continually in a work-in-progress state. The world is constantly changing, and I am constantly learning. I will update them as needed. Please feel free to view the "History" button on the right sidebar to watch the evolution of these notes, which are stored in git.

content/tags/observations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Observations about things. I would probably consider this the most structured content on this site, focusing on something I discovered or learned and wanted to document.
1+
Observations about things. I would probably consider this the most structured content on this site, focusing on something I discovered or learned and wanted to document.

content/tags/thoughts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Just general thoughts about things. Not necessarily fully formed or analytical in nature, just musings, often opinionated.
1+
Just general thoughts about things. Not necessarily fully formed or analytical in nature, just musings, often opinionated. I try to keep these as a snapshot of my mindset at a given time, but I will correct any factual errors. If I have new additional thoughts, I will do this with an errata in the footnotes or new section, and not try to overwrite an old perspective.

content/technology/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Stuff about technology. I'm mostly focusing on programming, but I do have a fascination with hardware, and not enough money or skill to really focus on it.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Notes about programming! I'm not really sure the best-way to organize this, as programming involves a lot of moving parts, of which includes the language of choice, how the language interfaces with the operating system, etc.
2+
3+
So, this is organized as "best-effort", basically. I try to jot down interesting things as I find them. Use the search bar for anything specific!

content/computers/programming/macos/macos-native-docker.md renamed to content/technology/programming/macos/macos-native-docker.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
tags:
3-
- docker
43
- observations
54
title: Docker on MacOS with close-to-native performance
65
---
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
tags:
3+
- notes
4+
---
5+
- Python threading by default is the worst of both words. In its current form, it sucks, completely.
6+
- Threads are **concurrent** but not **parallel**. Each thread created also corresponds with an os thread (pthreads on unix, for example), but only one "thread" can perform work at a given time.
7+
- This is due to the **Global Interpreter Lock** (GIL), which only allows one thread to run at every given time.
8+
- Despite the Global Interpreter Lock, it does not guarantee safety. Operations in Python in general, are not guaranteed atomic.
9+
- For example: the statement `x += 1` invokes multiple different bytecode instructions, the GIL may pause the thread in the middle of execution of this statement and other threads can observe the state beforehand, leading to data races and "undefined behavior".
10+
- In this case, the GIL is *preemptive* multithreading not *cooperative* multithreading. This is also similar to how OS threads operate. But in this case, the GIL doesn't necessarily control when threads run, the OS does, but it does control the *lock* that determines whether threads can run.
11+
- The OS and the GIL often have orthogonal interests when it comes to determining which thread gets to run!
12+
- OSes obviously do not want to let programs determine when their threads get to run (cooperative), as the OS has a broader view of all the various programs on a system asking for resources and needs to properly schedule everything.
13+
- Note: OSes *do* have a form of cooperative multithreading, called *fibers*. I don't know much about them. I hope someday I do!
14+
- [Reference](https://stackoverflow.com/questions/33352298/how-does-python-handle-thread-locking-context-switching), [Another Reference](https://verdagon.dev/blog/python-data-races).
15+
- Note that the Global Interpreter Lock is **not** part of the Python specification. It's part of the reference implementation, CPython, but there are several Python interpreters (such as [IronPython](https://github.com/IronLanguages/ironpython3), based on .NET) that do not use a GIL at all (in the case of IronPython, the synchronization is done by the underlying .NET runtime).
16+
- There are efforts to remove the GIL, culminating in [PEP 703](https://peps.python.org/pep-0703/), which has been accepted, and will make the GIL optional in Python 3.13.
17+
- This does come at a reduction to single-threaded performance (estimates ~10%), but there are already initiatives to increase Python's speed ([Faster CPython Team](https://devblogs.microsoft.com/python/python-311-faster-cpython-team/)) so the net impact is likely negligible per release.
18+
- `nogil` Python may become the default in the future. It doesn't affect Pure python code (since as I've pointed out, the GIL doesn't prevent data races), but CPython extensions will need to be recompiled.
19+
- Most CPython code is heavily optimized and doesn't necessarily assume a GIL context (does the synchronization) by itself, so this won't require huge rewrites, in general. It does require a recompilation on the right ABI.
20+
- Note: Python wants to avoid a 2->3 fiasco again which very nearly killed the entire language, so the design is conservative to ensure that gil->nogil won't break existing code. If it detects code that relies on the GIL, it will automatically switch to a GIL context.
21+
- Threads aren't necessarily pinned to core (TODO: Find more information about this), so this invokes context switches, even if `nthreads < ncores`. [Reference](https://discuss.python.org/t/python-context-switching-how-is-it-done/8635).
22+
- Context-switching is expensive! The speed of IO has increased tremendously with technologies like NVME, etc.
23+
- If a thread gets moved to a different core, that can invoke cache misses. The thread context will get "serialized" then "deserialized" on the core for execution.
24+
- This can be mitigated by a `ThreadPool` (which is recommended anyways in nearly all sort of multithreaded programming in all languages, since the creation and destruction of threads are expensive).
25+
- Async Python partially mitigates the preemptive-ness of the GIL, instead with cooperative multithreading as functions can signal when to give up control with an `await`.
26+
- However, Async Python is still single-threaded. The way tasks are run is agnostic to *how* they're run, its an implementation detail.
27+
- Though in practice, we can't have a mulithreaded executor in Python.
28+
- Python futures are defined by the coroutine, which is very similar to Rust's `futures`! It's just a function that's transformed into a finite state machine.
29+
- [`uvloop`](https://github.com/MagicStack/uvloop), for example, is an async runtime based on `libuv` (which powers Node.js) that makes the default `asyncio` runtime much faster. I believe it's multithreaded (don't quote me on this!)
30+
- However, in Python code that interfaces with the "outside world" (ie. Cython, Pyo3, etc.) is allowed to release the GIL.
31+
- This is prevalent in numpy, tensforflow, etc. Python is kinda a glorified bash here, with the actual work being deferred to the underlying "low-level" code.
32+
- Read/write/IO functions often do release the GIL (since the "Pure Python" in this case is just CPython which is doing syscalls, etc).
33+
- So in practice, we can get "true multithreading" in Python. But you don't get to control the semantics of when this multithreading occurs, it's done when the program essentially feels liek it.
34+
- Multiprocessing is the alternative for people who want **parallel** execution, as in this case, the Python Interpreter *forks* itself and provides an ergonomic API over this.
35+
- Each Interpreter gets its own GIL, so multiple interpreters can run code at the same time.
36+
- Theoretically, you can do *multithreading* per *multiprocess*, but I haven't explored the ergonomics of this or if it even really makes sense.
37+
- However, each process has its own separate address space, which can be *very* expensive.
38+
- Similar to `ThreadPool`s, `ProcessPool`s mitigate the creation and destruction of separate address spaces.
39+
- Processes have to communicate via IPC. Python makes this transparent-*ish* to you, by sharing objects between threads by [pickling them](https://laszukdawid.com/blog/2017/12/13/multiprocessing-in-python-all-about-pickling/).
40+
- This can suck. The most obvious reason is that deserializing and serializing an object invokes a real run-time cost.
41+
- It also means that for objects that can't/don't be pickled, you need to define your own custom logic for sending it across processes, while you don't care with threads.
42+
- Arguably, Python's ergonomics here are not really correct, and it abstracts the real complexity away from the user. But I digress.
43+
- In short: Python is not well-suited for true parallel workloads. In the current form of Python (as of 3.12), it is impossible to run *truly parallel* workloads in "pure" Python.

0 commit comments

Comments
 (0)