HNHacker News
TopNewBestAskShowJobs

mmozeiko

698 karma · joined July 27, 2011

https://github.com/mmozeiko/
submissionscomments
mmozeiko··on What I run on my $10 USD OpenStick homelab
Another small standalone single-binary rss reader is https://nkanaev.github.io/yarr/en/

It also supports fever api so you can use all kinds of mobile clients. The binary is smaller, and I prefer three column layout for reading on web.

mmozeiko··on Galois Finite Fields and the Advanced Encryption Standard (AES)
> Inverses exist for each operation, which makes decryption possible.

It is worth mentioning that in modern AES usage this feature does not really matter, because block cipher is used in CTR mode. In CTR block cipher is used to create long keystream bytes (pretty much one-time-pad key). This keystream gets xor'ed with plaintext to get ciphertext. Then getting from ciphertext back to plaintext is exactly the same xor operation with same keystream, no inverse AES operations needed.

mmozeiko··on Branchless Rust: Making a Filter 4x Faster by Removing an If
See the following pdf for example on how to do this with SSSE3 (pages 104-133) or even SSE2 (pages 151-173)

https://deplinenoise.files.wordpress.com/2015/03/gdc2015_afr...

mmozeiko··on XOR'ing a register with itself is the idiom for zeroing it out. Why not sub?
sub is also recognized as zeroing idiom for register file. Intel documents these in "3.5.1.7 Clearing Registers and Dependency Breaking Idioms" from Optimization Reference Manual: https://www.intel.com/content/www/us/en/developer/articles/t...

Here's html version: https://zzqcn.github.io/perf/intel_opt_manual/3.html#clearin...

AMD has similar list in "2.9.2 Idioms for Dependency removal" from "Software Optimization Guide for the AMD Zen5 Microarchitecture" document: https://docs.amd.com/v/u/en-US/58455_1.00

mmozeiko··on Too much discussion of the XOR swap trick
xor swap trick was useful in older simd (sse1/sse2) when based on some condition you want to swap values or not:

  tmp = (a ^ b) & mask
  a ^= tmp
  b ^= tmp
If mask = 0xfff...fff then a/b will be swapped, otherwise if mask = 0 then they'll remain the same.
mmozeiko··on Show HN: Svglib a SVG parser and renderer for Windows
How does it compare to rendering SVG by Direct2D itself? When using ID2D1DeviceContext5::DrawSvgDocument method, and ID2D1SvgDocument can be loaded from file with ID2D1DeviceContext5::CreateSvgDocument + SHCreateStreamOnFileW.
mmozeiko··on Novel OpenGL Pixel Shader Dewarping
Ah, I see. Yeah, then the current approach is fine.
mmozeiko··on Novel OpenGL Pixel Shader Dewarping
From what I understand from code those unwarps are just doing matrix multiply to get unwraped pixel location? In this case doing these operations directly in fragment shader instead of texture lookup will be faster. Memory bandwidth is not free. But simple ALU like this (just couple FMA's) can easily hide in shadow of texture sampling that happens afterwards. So simply upload those undistortion matrices (mat1 & mat2) as uniforms and do matrix multiply in shader for adjusting texcoords.
mmozeiko··on I designed my own fast game streaming video codec – PyroWave
There's also Windows.Graphics.Capture. It allows to get texture not only for whole desktop, but just individual windows.
mmozeiko··on Signal to Windows Recall: Drop Dead
I don't know why Signal calls it "DRM" because the do not use DRM for this. Typically DRM means encryption & keys are involved (which is what Netflix & others are doing with Widevine or PlayReady).

All Signal does is just a simple Windows API call to exclude window from screen capture. SetWindowDisplayAffinity function with WDA_EXCLUDEFROMCAPTURE argument: https://learn.microsoft.com/en-us/windows/win32/api/winuser/...

mmozeiko··on A leap year check in three instructions
If you change logic and/or to bitwise and/or then it'll be branchless.
mmozeiko··on Fast-PNG: PNG image decoder and encoder
https://github.com/veluca93/fpnge is a very fast png encoder. A bit lower compression ratio, but runs significantly faster than alternatives. Here is a presentation with benchmarks:

https://www.lucaversari.it/FJXL_and_FPNGE.pdf

mmozeiko··on AVX Bitwise ternary logic instruction busted
There is a simple way to get that immediate from expression you want to calculate. For example, if you want to calculate following expression:

    (NOT A) OR ((NOT B) XOR (C AND A))
then you simply write

    ~_MM_TERNLOG_A | (~_MM_TERNLOG_B ^ (_MM_TERNLOG_C & _MM_TERNLOG_A))
Literally the expression you want to calculate. It evaluates to immediate from _MM_TERNLOG_A/B/C constants defined in intrinsic headers, at least for gcc & clang:

    typedef enum {
      _MM_TERNLOG_A = 0xF0,
      _MM_TERNLOG_B = 0xCC,
      _MM_TERNLOG_C = 0xAA
    } _MM_TERNLOG_ENUM;
For MSVC you define them yourself.
mmozeiko··on Things you should know about Windows Input, but would rather not
Unfortunately not everything. For example, no xbox 360 controller support: https://github.com/microsoft/GDK/issues/39
mmozeiko··on Use Midnight Commander like a pro (2015)
It is called far2l: https://packages.debian.org/search?keywords=far2l&searchon=n...
mmozeiko··on Far Manager: files and archives in Windows
Alt + start typing jumps to file/folder with this name.

Ctrl + enter puts currently selected file/folder name into command-line.

Ctrl + O hides panels and shows you "background" with all the previous command outputs.

Custom editor can be set in F9 -> Options -> Editor settings.

mmozeiko··on Far Manager: files and archives in Windows
I recommend Polygon as virtual filesystem for SQLite database files: https://plugring.farmanager.com/plugin.php?l=en&pid=973

PortaDev for accessing MTP mounts (like Android): https://plugring.farmanager.com/plugin.php?l=en&pid=933

DiskMenu for adding custom locations in Alt+F1/F2 menus: https://sourceforge.net/projects/farplugs/files/DiskMenu/

And if you're running Far under ConEmu, copy ConEmu\Plugins\ConEmu folder into Far's Plugins folder. It will do better integration with ConEmu (there will be bunch of new ConEmu related features under F11 menu in Far).

mmozeiko··on Far Manager: files and archives in Windows
On Ubuntu this seems to be official (?) ppa: https://launchpad.net/~far2l-team/+archive/ubuntu/ppa Make sure "far2l-gui" is installed.

On ArchLinux there's package in AUR: https://aur.archlinux.org/packages/far2l-git (I maintain it).

Don't know details for other distros.

mmozeiko··on Far Manager: files and archives in Windows
Make sure you run wxgtk build, not the terminal one. Terminal is limited on what shortcuts it can do. But wxgtk build runs exactly as windows counterpart - Alt+F1/F2 and many other shortcuts work fine.
mmozeiko··on The least interesting part about AVX-512 is the 512 bits vector width
Here's a fancy trick from LLVM source: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Targ...

  #define A 0xf0
  #define B 0xcc
  #define C 0xaa
And then you can build immediate for VPTERNLOG operation by writing bitwise expression with A/B/C values in source code.

For example, A^B^C=150. A^(~B&C)=210. And so on...

Also mentioned by Fabian here: https://twitter.com/rygorous/status/1187032693944410114

mmozeiko··on Ask HN: Best way to play old games that require Windows 98/XP?
There's also dxwrapper that implements old DirectDraw/3D interfaces with newer D3D9 api for better compatibility with newer Windows versions:

https://github.com/elishacloud/dxwrapper

mmozeiko··on Win32 App Isolation
I'm pretty sure such thing is implemented by hooking OS functions that are dealing with directory enumeration, create/open file, etc - and then redirecting to custom code that provides virtual files & their contents. There's no standard Windows API for that, aside writing custom driver. But hooking such functions is relatively straight forward process because they are imported from well known shared libraries - you just need to make sure you hook all the functions that are relevant to filesystem operations.
mmozeiko··on C++ at the End of 2022
Not fully open-sourced. There are bunch of pieces that are available only in compiled form - .obj/lib files. Like math.h functions.
mmozeiko··on Brotli-G: A GPU compression/decompression standard for digital assets
You can use it for any workload that can use D3D12 buffers or textures as input. All the API does for you is transfer data from disk to ID3D12Resource object. After that it is up to you to do whatever you want - use it for fragment shader or compute shader input, etc.. If you use other api's like cuda or vulkan, then you'll need to use interop to create their resources using D3D12 backed resource (or do a copy, whatever is possible there).
mmozeiko··on Escaping strings faster with AVX-512
It is there to process last <32 elements. The vectorized loop processes up to 32 elements per iteration. The iteration does not happen if there are less than 32 elements left, because it wants to load 32 bytes as input. This is very typical in vectorized loops - process N elements per iteration and second loop that does tail of <N elements.
mmozeiko··on FLAC 1.4.0 released – added support for 32-bit audio
Btw there are alternative flac encoders, like FLACCL using GPU: http://cue.tools/wiki/FLACCL It compresses much faster than software libflac and gives smaller output files.
mmozeiko··on On self-modifying executables in Rust
That's not really what's happening with such C++ code. `static` variables are placed in normal writeable global memory. Only difference with such static is that compiler generates extra "bool" variable and checks it to initialize obj only on first run (threadsafe on C++11 and up).

You can see example here: https://godbolt.org/z/7f1qbh5r5

There are no code modifications - all compiler generated is extra byte check ("if" statement) and then acquire/release lock around constructor to be threadsafe.

mmozeiko··on Show HN: 10-40% faster LZMA decoder using x86 CMOVcc
To me it looks like something related to some other optimization pass (I don't know much about gcc passes). But not related to writes to memory. Here are two writes both using cmov (on different code): https://godbolt.org/z/n3dTrPo6e

Edit: compiling your code without modifications, but with `-Os` also gives two cmov's: https://godbolt.org/z/r86azb7be

mmozeiko··on Show HN: 10-40% faster LZMA decoder using x86 CMOVcc
Here are two cmov's with gcc: https://godbolt.org/z/j9bcv639c
mmozeiko··on Wcap: Simple and efficient screen recording utility for Windows
The reason I wrote wcap to use for myself is because Game Bar recording is super unreliable for me. I have 144Hz monitor but it records with some weird framerate, typically 36, sometimes some crazy fraction like 36.86 fps. I often want to get every single 144Hz frame out to analyze/see differences. It used to be that it also abruptly stops recording without any indication why, maybe that's improved now, but that is what I remember when I used it.

I think it also does not allow recording desktop or windows explorer. Sometimes I want to record a video of "here's how to do thing X in Windows itself" and send to somebody.

Additionally I wanted automatic resize to smaller (1080p) video when recording higher resolutions. Sure you can do that in post-processing, but that's extra tools & time.

Also every time I press Win+G after not using a while, it is a bit overwhelming and confusing to see all those buttons and signing into your "xbox social" - all I want is local video not some friends list.

Page 1 of 5Next →