Stefano Cristiano
pagghiu.bsky.social
Stefano Cristiano
@pagghiu.bsky.social
Principal Research Scientist@NVIDIA
(Omniverse Physics)
Author of "Sane C++ Libraries"
https://github.com/Pagghiu/SaneCppLibraries
Videos: https://youtube.com/@Pagghiu
Site: https://pagghiu.github.io
Opinions are my own.
Sane C++ Libraries - October 2025

✅ Further reduction of internal dependencies
✅ Bring Your Own Containers example (InteropSTL)
✅ New bootstrap for SC::Tools written in C++
✅ Increased test coverage
✅ Improved CI
✅ Fixes

github.com/Pagghiu/Sane...
#cpp #cplusplus
November 1, 2025 at 10:40 AM
Sane C++ Libraries - September 2025

✅Get rid of many inter-library dependencies
✅Stop accidental dependencies additions in CI
✅Free most libraries from dynamic allocation
✅Transform Build from lib to app
✅Add GDB Pretty Printer
✅Many smaller fixes

github.com/Pagghiu/Sane...

#cpp #cplusplus
September 30, 2025 at 10:31 PM
I've been adding to Sane C++ Libraries a GDB debug visualizer (pretty printer in gdb terminology) taking care of strings and containers.

In addition to the already existing ones for LLDB and MSVC Debugger (.natvis) I think we should be good now!
#cpp #cplusplus
September 5, 2025 at 7:19 PM
Sane C++ Libraries are now available as amalgamated single-file libs!

They can be amalgamated offline or directly in-browser at: pagghiu.github.io/SaneCppLibra...

Each amalgamation lists dependencies on other amalgamated libs and the LOC of its header vs. implementation sections.

Have fun!
#cpp
August 11, 2025 at 1:51 PM
I have been removing many inter-dependencies between Sane C++ "Libraries" (mainly Strings/Memory/Containers)

The following libraries do not allocate anymore! 🎉

✅ Async
✅ File
✅ FileSystem
✅ FileSystemWatcher
✅ FileSystemIterator
✅ Process
✅ Socket

See: pagghiu.github.io/SaneCppLibra...

#cpp
July 23, 2025 at 8:21 PM
I have been adding to Sane C++ Libraries some async primitives needed to send and receive bytes to and from UDP sockets (sendTo and receiveFrom).

As always implemented for IOCP, kqueue / epoll and io_uring!

Documentation:
pagghiu.github.io/SaneCppLibra...

Commit:
github.com/Pagghiu/Sane...

#cpp
June 11, 2025 at 8:25 PM
I've added a ProcessFork class to Sane C++ Libraries after discovering that "fork" on Windows can be approximated with RtlCloneUserProcess.
There are a ton of limitations but it's useful to serialize a data structure without blocking for IO or copying it for async IO.
Nice!
#cpp
April 12, 2025 at 6:49 AM
An example of "struct dumping" in Sane C++ Libraries.
Anything SC::Segment based (Vector / String / VectorMap etc.) can be dumped and restored by just casting it (well, start_lifetime_as 🤭).
I guess it's not rocket science but recent additions make creating this simple and easy.
#cpp #cplusplus
April 5, 2025 at 7:06 AM
While debugging some of the recent container issues for Sane C++ Libraries I have been starting to track the number of allocation and deallocations calls.

The test suite by itself is doing 20K allocations and ~50K re-allocations 🫠.

Is it MAYBE time to add support for custom allocators? 😅
March 18, 2025 at 9:43 PM
I have been slapping volatile where I think it makes sense to force the optimizer think twice about making weird assumptions around that code.
Hopefully this will not be so bad performance wise.
I could maybe replace that offset == 0 conditional with some branchless code to improve things further...
March 17, 2025 at 11:14 PM
Most SSO implementations I have seen use an union of pointer+size and the buffer. They discriminate the union depending on value of capacity (if > than buffer array size then you’re on the heap and viceversa).
There is no pointer arithmetic in this case, correct.
March 13, 2025 at 10:30 AM
Actually the second accepted answer from the SO post I've been linking above provides a more fundamental explanation about why this pointer arithmetics (that we all have done at least once 😜) has been declared UB (assuming it's being written by someone who knows...)
stackoverflow.com/a/67437638
March 13, 2025 at 8:38 AM
I am not a language lawyer but I've observed that without std::launder GCC optimizer figures out that segment.getData() == newData and possibly proves that newData is not stored anywhere (probably because pointer arithmetics like I'm doing in setData is UB) and it entirely removes the memmove call 🤯
March 11, 2025 at 9:17 PM
I've found however some actual UB manifestations on GCC under -O2.
I have been pretty shocked to see GCC "optimizing away" some memcpy of the reconstructed pointer from "this" + offset.
To get avoid such UB I've had to add volatile to the methods reconstructing the original absolute pointer.
March 9, 2025 at 10:50 PM
December 27, 2024 at 1:25 PM
🟩 SC::Hashing
Compute MD5, SHA1 or SHA256 for a stream of bytes

🟢 C Bindings

🟥 SC::Http
Http parser, client and server

🟢 Improved to the level of self-hosting project blog (non-production)
December 23, 2024 at 1:29 AM
🟩 SC::FileSystemWatcher
Files and directories notifications (Add, Remove, Rename, Modified).

🟢 Improve reliability
🟢 Support iOS using the (private) FSEvents framework

🟩 SC::FileSystem
File System Operations files and directories

🟢 Improve reliability
🟢 Symlinks creation
December 23, 2024 at 1:29 AM
🟨 SC::Plugin
Minimal dependency based plugin system with hot-reload

🟢 Allow overriding sysroot path
🟢 Capture compiler and linker output
🟢 Use environment CFLAGS / LDFLAGS
🟢 QueryInterface-like mechanism
🟢 Include paths
🟢 Detect Visual Studio Path
December 23, 2024 at 1:29 AM
🟩 SC::Process

Create Child processes, chain them, read outputs.

🟢 Improve API ease of use
🟢 Improve stability and reliability on Posix
🟢 Support custom working directory
🟢 Support custom environment variables
🟢 Support ignoring child process stdout/stderr
December 23, 2024 at 1:29 AM
🟨 SC::Build

Minimal self-hosted build System where builds are described in C++

🟢 Linux: Makefiles
🟢 macOS: Makefiles + XCode
🟢 Windows: Visual Studio Projects
🟢 Multiple Configurations / Architectures / Projects
🟢 Documentation / Coverage
🟢 Downloads dependencies
December 23, 2024 at 1:29 AM
SC::Tools

Single C++ files, self-bootstrapped on the fly, linking to Sane C++ Libraries for immediate execution.
They replace all shell scripts in the project with real C++ programs (repo / CI)

🟢 SC::Build - Build system
🟢 SC::Package - Host Tools downloader
🟢 SC::Format - Clang-Format helper
December 23, 2024 at 1:29 AM
SCExample

WIP example browser showcase for the library

🟢 Based on Dear ImGui and sokol libraries ❤️
🟢 Power Efficient: redraws on SC::Async IO or input events
🟢 Hot-reloaded on the fly through SC::Plugin
🟢 Integrates SC::Async with native event Loop
🟢 Supports macOS, iOS, Linux and Windows
December 23, 2024 at 1:29 AM
🟨 SC::Async I/O Library

Think of a simplified libuv / Boost.ASIO 😌

🟢 No allocations!
🟢 Socket operations (send/receive/connect/accept)
🟢 File operations (read/write/close)
🟢 Child process watcher
🟢 Folder watcher
🟢 Background Threaded Work

Backends
🟢 epoll
🟢 io_uring
🟢 kqueue
🟢 IOCP
December 23, 2024 at 1:29 AM
Hey, I just figured out that I've never been posting on BlueSky how nice the API from SC::Process from Sane C++ Libraries has become with the improvements added over the course of this year!

Check it out if you need to spawn some processes with I/O redirection!!! 🤭
pagghiu.github.io/SaneCppLibra...
December 14, 2024 at 3:21 PM
🎉 New Sane C++ Libraries Video!

Today I'm implementing an Async Socket Streams abstraction (akin to node.js streams).

So far it can asynchronously read test data from a file, pipe it to a socket, read it from the other socket side and pipe it to a file.

Enjoy the video!

youtu.be/0x6TLV_ig-A
#cpp
November 13, 2024 at 6:14 PM