HNHacker News
TopNewBestAskShowJobs

joconde

465 karma · joined August 25, 2021

submissionscomments
joconde··on Ask HN: FOMO by working in startups only vs. Big companies
I'm at one and it's pleasant. Pay is smaller than my country's large corps, but I can basically work on all projects and do things however I like. There is ML research as well as interesting dev projects.

It's sometimes annoying to see people use lazy solutions and refuse to learn the proper way, but since I took ownership of the important modules I use early on, I've built a small bubble of good software I can build upon.

joconde··on WebAssembly: The New Kubernetes?
PyInstaller is hackish though, I had to add tricks to setup.py by trial-and-error until I found why some config file or sub-module of a sub-package wasn't included when everything else was. It's also slow to launch, because it extracts the code into a temporary directory before importing python.dll, which then imports all the rest.

Containers are fine for a server after installing the runtime, which is already one too many steps. There isn't a self-contained app format that can run without installing something else before starting it.

joconde··on More than 1M fewer students are in college, the lowest numbers in 50 years
> Also, in-state tuition for state schools is much less than $50k/yr so try going to Cal and/or your best local public school and supplement with self teaching (e.g. via public/free lectures from MIT)?

Unrelated question: does "Cal" mean Berkeley here? Do you really need to "supplement it with self-teaching"? I don't really understand why state schools are viewed that way, since Berkeley consistently ranks world top-10.

joconde··on U.S. Justice Department forming unit to counter domestic terrorism
And now you have people wanting the exact opposite (a de facto tyrant, in power because an election was overturned) trying to get their way.

More precisely: making a freely elected government more vulnerable to violence won't yield an improvement.

joconde··on U.S. Justice Department forming unit to counter domestic terrorism
> Last week he makes a very divisive speech, with language like "I will stand here in the breach to fight this battle" -- is he throwing down fighting words to incite people?

After Congress was attacked to try to overturn an election, I think "battle" isn't the wrong word.

> Last week he makes a very divisive speech

It divides people who want to overturn elections from those who don't, I guess. That doesn't seem like a bad thing.

Call it whataboutism, but his predecessor's speeches were much more divisive, and for worse reasons.

Here's a quote from him before the capitol attack [1]:

> “Republicans are constantly fighting like a boxer with his hands tied behind his back. It’s like a boxer. And we want to be so nice. We want to be so respectful of everybody, including bad people. And we’re going to have to fight much harder. …

> “We’re going to walk down to the Capitol, and we’re going to cheer on our brave senators and congressmen and women, and we’re probably not going to be cheering so much for some of them, because you’ll never take back our country with weakness. You have to show strength, and you have to be strong.”

To summarise: Fight, but don't be violent. Go to the capitol, cheer, but actually don't, and definitely don't be weak. We're getting hit and we're so nice [nothing else said, but that's definitely implied to be a bad thing].

I wouldn't do it differently if I wanted to incite violence while keeping a way of pretending I didn't in court.

[1] https://www.nytimes.com/2021/01/10/us/trump-speech-riot.html

joconde··on U.S. Justice Department forming unit to counter domestic terrorism
> The world would be a better place if more politicians and their ilk were terrified of the people.

Giving more weight to people willing to threaten violence won't fix your problems.

joconde··on U.S. Justice Department forming unit to counter domestic terrorism
> we need a new standing paramilitary force?

Where do you get "paramilitary" from? This is the Justice Department, not the FBI. All the article says is:

> the new unit will be part of the National Security Division and will work to "ensure that these cases are properly handled and effectively coordinated" across the department and around the country.

That seems to imply a bureaucratic effort, nothing like what you're claiming.

> those people actually got inside and just milled around. there was no plot, no mission.

Some photos suggest otherwise [1].

> isnt it established fact the fbi had agents actively provoking the mob? known persons on video involved, not being prosecuted?

No. Care to provide sources?

[1] https://www.theguardian.com/us-news/2021/jan/10/us-capitol-m...

joconde··on Gunicorn
> To do anything with a request you are going to have a context which will function just like the stack of a thread.

But a thread has a separate call stack. Returning and calling another function in the same stack just involves moving the stack pointer by a few bytes. Switching to another thread’s stack will invalidate much more cache, while running an async task until await will make the best use of the existing cache, and switch (much closer in RAM than in another thread) only when it makes sense, i.e. the previous task started waiting on something.

> It only matters if you are at capacity because otherwise the active requests will be cached.

CPU cache is a few megabytes. That definitely won’t hold hundreds of requests if they all transfer substantial data, even if you can handle thousands or more.

joconde··on LastPass appears to be holding users' passwords hostage
In 1Password:

- the master key derives from 1. your password, and 2. a long, random key that you type manually on each new device (so you can’t brute-force the password just from the server’s data, and you can’t decrypt the data just from your hard drive without the master password),

- none of these keys ever leave your devices (encryption and decryption happen client-side),

- the key is deleted from RAM, locking the vault, if you’re inactive for too long.

That makes some attacks hard. It will be defeated if malware can get 1. your secret key and 2. your master password. But in that case, your login cookies and what you type in login forms are vulnerable too, so there isn’t much difference.

joconde··on LastPass appears to be holding users' passwords hostage
1Password on desktop stores items in a standard SQLite database, in an open format: https://support.1password.com/1password-security/#transparen...

They also store regular copies of your vault in a backup folder. If Satan buys them and they try to lock you out, just decrypt your backups and move somewhere else.

joconde··on Gunicorn
> In either case you need to load the context for other requests.

For async tasks, it means return, then call. For threads, it means moving to an entirely different stack, somewhere else in memory. “Loading context” is more expensive in the latter case.

> Maybe using a stack means using more cache lines than coroutines, but you'd have to be right at the edge of capacity for active requests for it to matter.

Why? Cache doesn’t only speed things up when capacity is full. Anything we have to reload from RAM will take time to load.

joconde··on Gunicorn
In my case, I'm lucky to be using computation libraries that release the GIL.
joconde··on Gunicorn
In my case no, because I heavily use numpy, PyTorch, and other libraries that use C++ extensions and release the GIL during long operations. I easily use 24 CPU cores fully by submitting to one thread pool.

If you use pure Python for long tasks, you're right that a ProcessPoolExecutor would be better.

joconde··on Gunicorn
> FastAPI's docs tell you to use "def," yet the most basic Hello World example in the tutorial uses "async def."

Because that's the correct way. print("hello, world!") will block for a very short time, so it's not worth sending to a thread pool.

> In fact most, if not all, of the examples in the tutorial use "async def."

That's again because they show the correct way to use async.

Using async correctly, when it applies is preferable to a synchronous function. The docs encourage you to do it if you know how, and if your use case fits an async function.

> So I don't think it's surprising if developers new to FastAPI tend to use async by default.

It is to me, because the docs are clear:

- if you know your function can be made async properly, make it so,

- if your function blocks, use "def",

- if you don't know enough to choose, use "def".

People who complain that the event loop blocks too often simply haven't read the docs well enough.

joconde··on Gunicorn
But we have to switch from one stack to the other. If we do that more than necessary on thousands of threads, I imagine the cache will be used less efficiently. The problem is runtime, not RAM usage.
joconde··on Gunicorn
IIRC, coroutines are split internally into function calls, so switching to a task is actually just a function call from the event loop, in the same call stack.

Threads have separate stacks. Surely this costs at least a little, and adds up with the number of threads?

joconde··on Gunicorn
I agree that it's kind of a mess, but it's getting better with simpler APIs (like asyncio.to_thread()), and in practice you can just use the primitives you want and ignore the rest.

I haven't read the post in detail though, thanks for the link! Seems interesting.

joconde··on Gunicorn
> the minute you want to use a sync api from within async/await code it becomes a nightmare to manage

What's wrong with sending the sync code to a thread pool? My CPU-, disk- and database-intensive application is filled with calls like:

   result = await asyncio.to_thread(long_function())
...and its resource usage and performance are great.
joconde··on Gunicorn
> A green thread implementation will thrash just as much in your hypothetical scenario.

The million threads risk slowing each other down with context switches, preventing any from finishing in time. An async event loop will focus on one connection at a time until `await`, and at least finish the tasks it attempts.

I haven't been in this situation, but async seems to have real advantages here. With OS threads, you don't control scheduling without costly synchronisation primitives.

joconde··on Gunicorn
> Almost no one really understands asyncio

I'd very much like a source for that, because I don't feel like it's very hard to understand.

> syntax like "async def" and "async with" makes you feel like you do, and stuff like FastAPI encourages you to type "async"

FastAPI's docs tell you to use "def" if you don't know what you're doing. [1] says "If you just don't know, use normal def."

It's also pretty simple, I think. If your function blocks, use "def", and let FastAPI run it in a thread pool to avoid blocking the event loop. If it doesn't block, use "async", and take advantage of concurrent execution without needing a new thread.

[1] https://fastapi.tiangolo.com/async/

joconde··on Gunicorn
> That is exactly the problem with asyncio, the minute you want to do something a little more cpu heavy it blocks.

Isn't that by design? Sending CPU-heavy tasks to the default executor with asyncio.to_thread() works perfectly for me.

Or maybe this doesn't scale in your use-case, because of the thread count limit? (Although in that case, I don't think you'd be better off without asyncio.)

joconde··on BitTorrent v2 (2020)
These links are easy to mirror, they probably fit into a reasonably large SQLite file. Since the Web still allows decentralization, that doesn’t seem to be a problem. For example, the pirate bay is blocked in my country, yet I can still consult it on dozens of mirrors.
joconde··on I feel dumb(er) when typing, and smart(er) when writing
> I type 150+ WPM and can’t write to save my life.

Same, but writing still helps me think better.

Maybe typing is too guided, and having to organise my thoughts on paper makes the process more efficient.

joconde··on Why Apple’s iMessage is winning: teens dread the green text bubble
When was that? We've had free unlimited SMS/MMS for years in France, even on the cheapest plans at 10 euros/month. Now it's free to/from any EU country too.
joconde··on Modeling Uncertainty with PyTorch
What do "multi-level" and "mixed effects" mean? There are tons of non-linear models with lots of parameters, but I've never heard these other terms.
joconde··on Psychogenic death, the phenomenon of “thinking” yourself to death
Or they do it themselves by getting depressed and not taking care of themselves. Physical exercise and healthy meals take motivation.
joconde··on Psychogenic death, the phenomenon of “thinking” yourself to death
Living forever might not be that fun. People we know would still die for accidental reasons all the time. Maybe we can't cope with that for centuries or millennia and morale starts to take hits after a while.
joconde··on Linux Kernel RNG is now Blake2 instead of SHA1 and 3x faster
BLAKE3 was published in 2020. I don't think anyone would seriously use a hash function, cipher, or RNG that has been studied for only two years, let alone in the Linux kernel.
joconde··on Consider SQLite
Curious why you think that. We have an app that does computation using thread pools, and moving from manually-created threads to asyncio has made it much more efficient and robust.

Some advantages: cancellation and error handling are trivial, there's no need for error-prone thread coordination, threads don't have to waste time waiting on locks (because we use asyncio sync primitives instead, so we don't submit work to a thread pool unless it's doable right now with no wait).

Of course, it depends on the tasks being written correctly. But "don't block the event loop" is a much easier rule to follow than "don't deadlock these 10 different threads that share queues and locks".

We didn't write an entire OS with it, but I don't think that was ever the point of asyncio, was it?

joconde··on Consider SQLite
You can't do any serious neural stuff on 8GB of VRAM. I'd say save yourself some pains and buy the $3000 professional models with ECC so you can train transformers.
← PreviousPage 2 of 7Next →