Better HN
topnewbestaskshowjobs
Log inSign up

Tringi

18 karma · joined Jun 7, 2019 (7y ago) · 25 submissions

Submissions

comment 8mo ago · link · parent

I wasn't happy with existing solutions for clean shutdown of Azure Spot VMs so I put together this tiny service application that does basically what all those scripts do, but with way less resources and without continuously launching scripting engines.

It's nothing groudbreaking really. It detects that eviction is pending, usually 30s in advance, so it gives 10s notice and then initiates shutdown, properly noting the reason to Event Log.

It's open source and just a handful of lines of code, but way lighter than executing heavy script every second.

2.

Service for Clean Windows Shutdown on Azure Spot Virtual Machine Eviction(github.com ↗)

1 points · by Tringi · 8mo ago · 1 comment

comment 10mo ago · link · parent

An observation and a rant. Many will not even notice that icons got more blurry with Windows 10 and then worse, but I needed to get this off my chest, and perhaps I'll find likeminded minds in this regard through this.

4.

The abysmal state of Windows 11 Taskbar icons(github.com ↗)

6 points · by Tringi · 10mo ago · 2 comments

comment 1y ago · link · parent

It's a little more complicated if you are to be using themes, GDI and common controls. Some time ago I put together this example: https://github.com/tringi/win32-dpi

The high DPI support in Windows went through quite an evolution since XP, but mostly to fix what app programmers messed up. You can have nice and crisp XP at 250% dpi if you do things right, e.g.: https://x.com/TheBobPony/status/1733196004881482191/photo/1

comment 2y ago · link · parent

So how shall a launcher application determine which AArch64 ISA level is available on Windows on ARM device?

Full story: https://www.reddit.com/r/programming/comments/1gxnr85/determ...

7.

The trouble of determining current ARM64 ISA version on Windows on ARM(github.com ↗)

3 points · by Tringi · 2y ago · 1 comment

comment 2y ago · link · parent

There's this issue with Win32 synchronization API, discussed and documented in many blogs, videos and tutorials over the years, that comes up again and again, that one thread can only wait for 64 (MAXIMUM_WAIT_OBJECTS) kernel objects at the same time.

To work around this limit, programs have resolved to various unnecessarily complex solutions, like starting extra threads for the only purpose of waiting, refactoring the logic, or replacing events with posting I/O completion packets.

In fact, if the application is waiting in a Vista+ Thread Pool, the pool itself uses the first approach: Starts as many threads as needed to wait for all the events. Or rather it used to. With Windows 8, all Windows threadpool waits can now be handled by a single thread. It does it through a new capability of associating the Event with an I/O Completion Port, to which the signalled state is enqueued. But this capability was not exposed through Win32 API to regular programmers.

It was exposed though, by a barely document NT API NtAssociateWaitCompletionPacket, which, it seems, nobody is using, except a few rare high performance libraries, Rust runtime, and um security researchers.

So I took a liberty to abstract out the details and implement what a simple Win32 call could look like. In the following example I wait for 2000 events in a single thread, through a single IOCP.

> https://github.com/tringi/win32-iocp-events

Of course, for larger systems, the Thread Pool API is the right way. But if your program is already using IOCPs, is single-threaded and you don't have resources to solve locking and concurrency, or are just thread-pooling your own way, this may be the ideal solution to reduce thread count, complexity and resource requirements.

comment 2y ago · link · parent

Ah, yeah, that's true.

comment 2y ago · link · parent

As awesome as these algorithms are, I can never imagine use case.

Any time I need to turn something into uppercase or lowercase, it's user's input or something Unicode. Which can be in any random language, so all the crazy Unicode casing rules apply.

I mean, Czech could work by canonical Unicode decomposition and then re-composition afer case change ...but the input can be in Russian or Greek. I can't imagine accelerating that, or rather taking into account all the ranges.

comment 2y ago · link · parent

The Hub Event (working title) is similar to the standard Win32 Event Object, but multiple consumers (clients) of the event can reliably wait on them, while being set/reset by the producer.

When the software requires to signal/release all waiting threads, each exactly once, that are not necessarily in a single process. Where naïve approach would be to use the flawed PulseEvent API and the system does not already have established IPC by other means (IOCP).

The implementation is somewhat heavy for what it does, but I haven't figured out simpler one. Perhaps I'll get some ideas for v2 here. In fact I believe this thing should be provided as a another kernel object by the OS alongside events, semaphores, mutexes, etc.

12.

Win32 "Hub" Events / Reliable Alternative to PulseEvent API(github.com ↗)

2 points · by Tringi · 2y ago · 1 comment

comment 2y ago · link · parent

Some time ago I did some test, 256 threads competing on a small number of cache lines, and found out that all, CreateMutex, CRITICAL_SECTION and SRWLOCK, were quite fair.

The most successful thread was only 25%, 15% and 9% ahead of the least successful one. On the contrary, in my simple usermode spinlock the unfairness would be 1000% or even 2000%.

comment 2y ago · link · parent

Blocking new readers when a writer arrives is perfectly good and desirable. Blocking readers when the writer finishes, and there isn't any new queued, is definitely not.

comment 2y ago · link · parent

And Twitter/X accounts.

I have had a lot more things fixed in Windows or MSVC from nagging devs on there than from reporting through any official channel.

comment 3y ago · link · parent

I'm always fascinated when engineers who make my year's salary in a week come up with something as dumb as this.

comment 3y ago · link · parent

A simple tool that I've created to solve a somewhat self-inflicted problem. In some projects I want or need small differences in DLL .def exports, differences by architecture or release/debug. And I don't want to manually maintain separate files. So because there's no preprocessing support for .def files, at least not in Visual Studio, I wrote myself this simple one.

Putting it out there in case anyone else finds it useful. Find usage example in the middle of the page.

18.

DLL Module-Definition (.def) Files Preprocessor(github.com ↗)

1 points · by Tringi · 3y ago · 1 comment

comment 4y ago · link · parent

Algorithm intended as a replacement for basic fast Ctrl+F search inside C++ sources.

Ignores insignificant whitespace, diacritics and is case insensitive. Can ignore comments/strings or search explicitly inside them. Matches camelCase and snake_case identifiers, 0 to NULL to nullptr. Does not distinguish between numeric notations. Optionally ignores all syntactic tokens, or braces, brackets or parentheses in particular. Ignores boomer comment decorations. Etc. For all specific options, see the docs.

20.

Better Ctrl+F search for C++ (coding style agnostic) proof of concept(github.com ↗)

1 points · by Tringi · 4y ago · 1 comment

comment 4y ago · link · parent

Yes, it is.

comment 6y ago · link · parent

Yes. 200 MHz down from base clock.

comment 7y ago · link · parent

I'm searching for it too, and I can't find the actual text. Somebody doesn't want us to begin mixing that cocktail ourselves :D

24.

Using 32-bit pointers in 64-bit code on Windows (benchmark)(github.com ↗)

1 points · by Tringi · 7y ago · discuss