Sabitlenmiş Tweet
Robert van Engelen, PhD
527 posts

Robert van Engelen, PhD
@vEngelenRobert
Follow me on Bluesky where science, math, tech, art and retro communities thrive
Katılım Eylül 2013
1 Takip Edilen150 Takipçiler

@tsoding Warning: isdigit is not valid for negative char, i.e. on non-ASCII when char is signed, which depends on the compiler. Also, isdigit is (or used to be?) locale-specific in the Microsoft world. Just use >=‘0’ <=‘9’.
English
Robert van Engelen, PhD retweetledi

For decades, computer scientists have been attempting to meld the airtight security of the zero-knowledge proof with the time-saving probabilistically checkable proof. They always failed to reach the perfect solution – until now. quantamagazine.org/computer-scien…

English

@ChShersh @carlo_dellacqua No. Code synthesis at any level must never break when dependencies are updated. If that’s the case, replace with your own logic to get rid of this mess. For 20+ years I’ve kept my source code generation tools stable.
English

@carlo_dellacqua Codegen tool version is not enough.
One of the dependencies may change version without changing a single line of code in the tool and you may get a completely different result.
English
Robert van Engelen, PhD retweetledi

@lefticus If C/C++ programmers don’t know operator precedence, then they should get a refresher video, not some scolding. Physicists, mathematicians and engineers don’t have a problem with their (terse) notation either. It is what it is, although implicit multiplication sure is evil 😱
English
Robert van Engelen, PhD retweetledi

Some day I’ll write a compiler that spits out Shakespearean insults for errors “thou tottering idle-headed bugbear forgot to insert a semicolon at line 42”
Journal of Art in Society@artinsociety
To creatively insult without actually swearing, just use this Shakespearean Insult Kit. Combine one word from each column, & preface it with “Thou”, to create satisfyingly impolite abuse such as “Thou beslubbering, pottle-deep clotpole” writerswrite.co.za/shakespearean-…
English

@HeyBirt When I replaced caps in my M100, I was surprised how many had leaked. None of that was visible on the PCB before cap replacement. Leakage damage was minimal, fortunately, but would have gotten worse over time. Some vias were clogged with oxidized solder & had to use a pin vise.
English
Robert van Engelen, PhD retweetledi
Robert van Engelen, PhD retweetledi

@abhi9u Immunity to vulnerabilities would be nice, but even the Rust devs screw up so don’t tell average devs they can’t make mistakes with Rust. It’s what happens to all maturing PL, so give it time for more stories to come out cvedetails.com/vulnerability-…
English

@abhi9u A false sense of a lack of risk is worse, which the industry is sometimes trying to sell. Basically, critical complex systems must be reviewed and extensively tested before deployment. Regardless of the programming language used. Rust won’t save any time or cost there.
English

Everyone is throwing their opinion around but I prefer to read what the experts have to say. Julio has a long history of working at the kernel level 👇
Julio Merino@jmmv
You know I'm a Rust fan, but... these posts saying that Rust would have prevented yesterday's CrowdStrike mess are rubbing me the wrong way. Rust would only help minimally. 👇
English

Keep moving forward. Don't look back! Surprised to see my research at my old CS department is well read. I left the dept 6 years ago as tenured full professor to work in my own R&D shop. Did I tell you I really enjoy working on interesting & challenging things? @ResearchGate

English

@moyix Can’t blame you, it’s great. 36 years of vi and vim for me. Still my daily driver to edit code, documentation, LaTeX etc.
English

With a heavy heart, I tell you that my father, Donald Sutherland, has passed away. I personally think one of the most important actors in the history of film. Never daunted by a role, good, bad or ugly. He loved what he did and did what he loved, and one can never ask for more than that. A life well lived.

English
Robert van Engelen, PhD retweetledi
Robert van Engelen, PhD retweetledi

Today I published a comprehensive 5000 word article on the design & implementation of the GC in CPython. Took me many weeks to get this out. Here's a summary:
CPython primarily uses reference counting for GC. Every object maintains reference count in its header and the runtime manipulates it to track how many references the object has. When the object's reference reaches 0, it immediately gets deallocated.
However, if the objects have a cycle of references in between them, then the vanilla reference counting implementation doesn't work. To handle this situation, there is a GC as well which detects cyclic references and if they are not reachable, then it breaks their cycle to get them deallocated by reference counting.
CPython uses a generational garbage collector, which has 4 generation: 1 young gen, 2 old gens and 1 permanent gen.
The GC generation is represented via this struct. It contains a doubly linked list to which objects are appended. Whenever the GC cycle triggers, this list needs to be traversed to scan the objects.
Not all the objects are tracked for GC in CPython. Primitive types, such as ints, floats, strings etc. don't need to be tracked by the GC because they cannot contain other objects and cannot participate in cycles. Only container type objects are tracked, such as lists, dicts, tuples, user defined classes etc.
To allow container type objects to be linked to the GC's linked list, these objects have an additional GC header where the linked list pointers are maintained.
When a container type object is initially allocated, it gets added to the young gen, and the count of objects in young gen is incremented. If that count has crossed the threshold then a GC cycle is scheduled.
The cycle is scheduled by setting a flag in the eval_breaker field in the thread state object. The thread state object maintains state information about the activities on the interpreter in the context of the current thread, such as current frame pointer, GC state, and eval_breaker.
The eval_breaker is a collection of flags to inform the interpreter about various async events that it needs to handle, such as signals, async exceptions, and GC. The interpreter checks the eval_breaker at the beginning or the end of certain bytecode instructions.
When the interpreter checks eval_breaker and notices that the GC cycle flag is set, it goes and invokes the GC code.
The current GC implementation in CPython scans the young generation and a fraction of one of the oldest generations (this is called incremental GC).
The GC algorithm starts scanning the linked list of objects to detect cycle. The algorithm is quite involved and I can't describe here, so check it out in the article.
At the end, the GC might have a list of objects that had cyclic references between them but could not be reached from anywhere else. For these objects, the GC invokes their tp_clear function.
tp_clear is a function pointer defined in the object header (inside PyTypeObject) which needs to be implemented by all the container type objects. tp_clear basically has to traverse to all the contained objects within the object and decrement their reference counts. Once, that happens, the cyclic of references will break and the reference counting mechanism will ensure that these objects get deallocated.
For the NOGIL implementation, the overall reference counting and GC continue to work as I've described above. But there are many internal changes to make them thread-safe, which I've described in the article (check it out, see replies).




English

















