Hacker News new | past | comments | ask | show | jobs | submit | ollien's comments login

What constitutes a garden? Does a small front lawn count?


Europeans use the word "garden" in the place where Americans would use "yard"


Great post! One question that lingered for me is: what are asynchronous safe-points? The post goes into some detail about their synchronous counterparts


I don't know, but I remember hearing in a talk that the compiler had to be modified to insert them into the generated code.

Here's `isAsyncSafePoint`: https://github.com/golang/go/blob/d36353499f673c89a267a489be...

edit: The comments at the top of that file say:

    // 3. Asynchronous safe-points occur at any instruction in user code
    //    where the goroutine can be safely paused and a conservative
    //    stack and register scan can find stack roots. The runtime can
    //    stop a goroutine at an async safe-point using a signal.


No, but a RISC-V partner-made mainboard was just announced.


I've heard that positive spin responded to with "this company is my biggest investment, I'm not going anywhere" :)


> In WET code (write everything twice) everything looks primitive, as if it was written by complete newbie, and every change needs to be added at multiple places, but each change is trivial and time to finish is predictable. I would go as far as calling the code boring. The most difficult thing is to resist the temptation to remove the duplicity.

This only scales so far. After some point, it's very easy to run into cases where you meant to change something everywhere but forgot/didn't know about others. Not to say everything should be so compartmentalized as to restrict change, but there is a balance to be had.


Which is why you need a balance between WET and DRY. DAMP = Don't Alter in Many Places.


I've never heard this one before, but I love it. Unfortunately we've also got "Don't Abstract Methods Prematurely" and "Descriptive And Meaningful Phrases".


Dumb Acronyms Must Pay?


Yes, what actually happens is that many code changes are released half-baked because logic only got updated in 1 (or 13) of the 14 places that needed to be updated, and the cussing and hair pulling just starts later.


Tests, baby


Tests don't really help you when a newly discovered bug affects logic copied in ten places and you're only aware of two of them. You can add a regression test to the places that you update, but not the others. And then if there's another bug discovered in the duplicated code, a different subset of the copies might get changed and have tests added. Suddenly it looks like these different versions of the repeated logic are intended to be behaving differently for some unknown reason even though the divergence is purely accidental.


Or, use a sufficiently well designed type-checking compiler, like GHC.


Pydantic falls into this box for me. The maintainer refuses to build API reference documentation, as they feel that there should only be one source of information. It's their project, of course, but every time I need to find a method on an object, I am scouring pages of prose for it. Sometimes it's just easier to read the source.


What's missing from the existing API documentation?

https://docs.pydantic.dev/latest/api/base_model/


Oh nice! I'll admit, my comment was based on outdated knowledge (the last time I used Pyandtic for a major project was in 1.x).

https://github.com/pydantic/pydantic/issues/1339


Haproxy does the whole documentation side of things very well.

The docs are very straightforward and thorough.


If you're in the market ever again, take a look at the Sony Linkbuds. I've enjoyed mine for exactly this reason


AFAICR it still "works" if you do a ton of manual setup. They basically said they're not going to support it because it's bad PR


It's bad PR because Apple is going to keep breaking it and then people go on social media and talk about how it doesn't work.


How do single-threaded programs benefit from a lack of GIL?


They don't benefit much from a lack of GIL, perhaps a small reduction in overhead. This feature is a first step towards being able to disable the GIL completely. It is intended to be implemented in a very conservative manner, bit by bit and so for this first step it should work for thread free code.


Disabling the GIL can unlock true multi-core parallelism for multi-threaded programs, but this requires code to be restructured for safe concurrency, which isn't that difficult it seems:

> When we found out about the “nogil” fork of Python it took a single person less than half a working day to adjust the codebase to use this fork and the results were astonishing. Now we can focus on data acquisition system development rather than fine-tuning data exchange algorithms.

https://peps.python.org/pep-0703/


>We frequently battle issues with the Python GIL at DeepMind. In many of our applications, we would like to run on the order of 50-100 threads per process. However, we often see that even with fewer than 10 threads the GIL becomes the bottleneck. To work around this problem, we sometimes use subprocesses, but in many cases the inter-process communication becomes too big of an overhead. To deal with the GIL, we usually end up translating large parts of our Python codebase into C++. This is undesirable because it makes the code less accessible to researchers.


Maybe they should look in to translating parts of their code base to Shedskin Python. It compiles (a subset of) Python to C++.


How's it different from Cython, which compiles a subset of Python to C or C++?


Shedskin has stricter typing, and about 10-100 times performance vs Cython.


Speed. Admittedly not quite as much so the way this patch is implemented, since it just short circuits the extra function calls, doesn’t omit them entirely.


Removing the GIL results in slower execution. Without the guarantees of single thread action, the interpreter needs to utilize more locks under the hood.


Not in single threaded code.


Umm, yes it does? For the longest time, Guido’s defense for the GIL was that all previous efforts resulted in an unacceptable hit to single threaded performance.

Read PEP-703 (https://peps.python.org/pep-0703/#performance) where the performance hit is currently 5-8%


That's to make it thread safe without the GIL.

If you only care about single thread there's all kinds of stuff you can do.


How to ensure there are no other threads, confidently enough that one can turn thread safety off?


From when I was reading the proposal, the idea is that until a C extension is loaded, you can assume that there are no other threads. Then when a module is loaded, by default you assume that it uses threads but modules that are thread free can indicate that using a flag, so if a module indicates it's thread free then you continue running without the thread safety features.


It could remove the locking/unlocking operations.


Removing the GIL requires more locking/unlocking operations. For single-threaded program, it's a performance penalty on average: https://peps.python.org/pep-0703/#performance


Doesn't removing the GIL imply adding back new, more granular locks?


Sort of, but the biased reference counting scheme they’re using avoids a lot of locks for the common case.


They don't.


I mean, you're not wrong, but also it's a huge feat to provide a toggle for a major feature like the GIL. Though, if it's just asyncio that's broken, perhaps it's not like removing your engine, but rather your antilock brakes :)

EDIT:

> [the test synchronous programs] all seem to run fine, and very basic threaded programs work, sometimes

Perhaps this is closer to removing the oil pan


Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: