Skip to content

Instantly share code, notes, and snippets.

Avatar

Stephan Sokolow ssokolow

View GitHub Profile
@Kestrer
Kestrer / how-to-write-hygienic-macros.md
Created Oct 17, 2020
A guide on how to write hygienic Rust macros
View how-to-write-hygienic-macros.md

How to Write Hygienic Rust Macros

Macro hygiene is the concept of macros that work in all contexts; they don't affect and aren't affected by anything around them. Ideally all macros would be fully hygienic, but there are lots of pitfalls and traps that make it all too easy to accidentally write unhygienic macros. This guide attempts to provide a comprehensive resource for writing the most hygienic macros.

Understanding the Module System

First, a little aside on the details of Rust's module system, and specifically paths; it is

@Ben-PH
Ben-PH / strace.md
Last active Jun 6, 2020
Comaprison of C and Rust syscalls on startup/shutdown.
View strace.md

Abstract

For some situations, understanding system calls made during processes start-up and shut-down can be valuable. For example, consider a shell-scripts long-running hot loop that runs a very short-running process. Thus it is perhaps reasonable to hypothesise that a difference in system calls during process start-up/shut-down has a non-negligable impact on the run time of said hot-loop.

This write-up looks at how C and Rust programs differ in terms of system-calls for start-up/shutdown. It is not intended as a performance analysis and only looks at one target system.

At the end, we take a quick look at using statically linked libraries by building with # cargo build --target x86_64-unknown-linux-musl --release and removing even more syscalls by removing the main function

System

View LetsDestroyC.md

Let's Destroy C

I have a pet project I work on, every now and then. CNoEvil.

The concept is simple enough.

What if, for a moment, we forgot all the rules we know. That we ignore every good idea, and accept all the terrible ones. That nothing is off limits. Can we turn C into a new language? Can we do what Lisp and Forth let the over-eager programmer do, but in C?


@goranmoomin
goranmoomin / issue-log-83.md
Last active Dec 3, 2020
actix-service Cell::get_mut() is unsound
View issue-log-83.md
@bb010g
bb010g / 000-actix-logs
Last active Oct 18, 2020
actix/actix-net#83, actix/actix-net#87
@HenningTimm
HenningTimm / rust_mem_profiling.md
Last active Mar 13, 2021
Memory profiling Rust code with heaptrack in 2019
View rust_mem_profiling.md
@robey
robey / apple1-rom.txt
Last active Jul 18, 2019
apple 1 ROM disassembly
View apple1-rom.txt
;
; the "monitor ROM" of an apple 1 fit in one page (256 bytes).
;
; this is my attempt to take the disassembled code, give names to the
; variables and routines, and try to document how it worked.
;
;
; an apple 1 had 8KB of RAM (more, if you hacked on the motherboard), and a
; peripheral chip that drove the keyboard and video. the video was run by a
; side processor that could treat the display as an append-only terminal that
View avx_sigh.md

why doesn't radfft support AVX on PC?

So there's two separate issues here: using instructions added in AVX and using 256-bit wide vectors. The former turns out to be much easier than the latter for our use case.

Problem number 1 was that you positively need to put AVX code in a separate file with different compiler settings (/arch:AVX for VC++, -mavx for GCC/Clang) that make all SSE code emitted also use VEX encoding, and at the time radfft was written there was no way in CDep to set compiler flags for just one file, just for the overall build.

[There's the GCC "target" annotations on individual funcs, which in principle fix this, but I ran into nasty problems with this for several compiler versions, and VC++ has no equivalent, so we're not currently using that and just sticking with different compilation units.]

The other issue is to do with CPU power management.

@alkis
alkis / the-case-for-deadlines.md
Last active Apr 19, 2018
The case for deadlines
View the-case-for-deadlines.md

The case for deadlines

Rust aims to be the foundation of fast and robust software. A thorn in that side is the choice of timeout-centric APIs for I/O and multithreading. I posit this was a bad choice and it needs to be remedied as soon as possible before more APIs proliferate this (possibly accidental) design decision.

Motivating example: time limited network client request

Task: connect to a remote server, send a request, receive response with an end-to-end timeout of 10 seconds.

Attempt #1