frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Securing Internet-Critical Software: How We Could Have Backdoored Bash

https://www.hacktron.ai/blog/hacking-gnu-savannah
1•kmm•3m ago•0 comments

Show HN: Rust crawler for SEO and content audits, with optional LLM review

https://crawler.siteone.io/
1•janreges•5m ago•0 comments

Magic vs. Wonder: memories of a distant future

1•nicfio•7m ago•0 comments

What factors shapes the future of UX learning?

https://docs.google.com/forms/d/e/1FAIpQLSfUrRL6qYGP_PlgqNdXRX_9dR92umWQAuetaGru1j02YG28rA/viewform
1•uxrabhi•8m ago•0 comments

Show HN: Safely connect GrokBot to your PC/VM: chosen folders and Claude/Codex

https://github.com/janreges/safe-grokbot-bridge
1•janreges•10m ago•0 comments

GTM Engineer Salary in 2026

https://gtmjobs.xyz/gtm-engineer-salary
1•meetvolley•14m ago•0 comments

Large-scale battery storage systems check their charge every 60 seconds, causing

https://www.fz-juelich.de/en/news/archive/press-release/2026/mystery-of-60-second-fluctuations-in...
1•fanf2•16m ago•0 comments

Photographer captures images of hundreds of satellites

https://www.stuff.co.nz/culture/361053243/kiwi-photographer-captures-images-hundreds-satellites-n...
3•hermitcrab•20m ago•0 comments

You can't create a different life while continuing to make the same choices

https://randomfuckingknowledge.substack.com/p/the-four-choices-that-change-how
1•TheCreativePrin•21m ago•0 comments

Europe's Fossil-Fuel Problem Has an Electric Solution

https://www.bloomberg.com/news/newsletters/2026-10-31/europe-s-fossil-fuel-problem-has-an-electri...
1•simonebrunozzi•23m ago•0 comments

North Korea Responsible for $6B+ Binance Attack

https://www.fbi.gov/investigate/cyber/alerts/2026/north-korea-responsible-for-6-billion-binance-a...
1•Wasserpuncher•27m ago•0 comments

IEEE Wipes Out 1,417 Papers over Sold Authorship

https://www.nature.com/articles/d41586-026-03455-8
1•haebom•27m ago•0 comments

DeepSeek Harness Superagent Prototype

https://github.com/deepseek-ai/dsh-superagent-prototype
2•orion_•28m ago•0 comments

Show HN: Portr – Expose local HTTP, TCP or WS connections to the public internet

https://github.com/amalshaji/portr
1•pixxxel•31m ago•0 comments

Pale Blue Dot (Book)

https://en.wikipedia.org/wiki/Pale_Blue_Dot_(book)
1•chistev•32m ago•1 comments

Towards Digital Garden

https://jaydip.me/notes
1•jdsane•35m ago•0 comments

Shops looted as German cost of living protests turn violent

https://www.bbc.com/news/articles/cqj34gnd3n30o
1•Betelbuddy•36m ago•0 comments

FreeGent: Free Agentic AI for Everyone

https://freegent.ai
1•anttttti•37m ago•0 comments

How to Unleash GStreamer for Low Latency Streaming with Red5?

https://www.red5.net/blog/gstreamer-for-low-latency-streaming/
1•mondainx•39m ago•0 comments

OpenIDEA: The IDE you know, rebuilt in Rust

https://github.com/l0ng-ai/openidea
4•theanonymousone•42m ago•1 comments

Scaling my 3rd app to first 1 k USD mrr at age 16

https://play.google.com/store/apps/details?id=com.exentoai.awaken&hl=en_US
1•akshitadityaaa•42m ago•1 comments

Hush Relay – Self-hosted encrypted messaging with one PHP file

https://github.com/altrudev/Hush-Relay
1•altrudotdev•44m ago•1 comments

TeamViewer RCE Vulnerability (CVE-2026-111585)

https://remedio.io/research/vulnerability-disclosures/remote-code-execution-in-teamviewer/
1•omrid-remedio•46m ago•2 comments

Six days, 742 turns, one chat window. A pseudonymised DeepSeek thread

https://github.com/UKA-135/deepseek-long-thread-record
1•pinuslongaeva•48m ago•0 comments

DeepSeek launches advanced coding agent to rival Claude Code

https://www.bloomberg.com/news/articles/2026-11-01/deepseek-drops-enhanced-coding-agent-with-aim-...
3•albert_e•50m ago•1 comments

AI-driven layoffs are creating a new class of boomerang employees

https://www.reddit.com/r/technology/s/bU94PCfFwr
4•zomtorg•50m ago•1 comments

Show HN: OpenProject Agent Engine – Automated Workflow and Agent Dispatch

https://github.com/310networks/openproject-agent-engine
1•kookster310•52m ago•0 comments

What operational task would you hand to a 7-day custom AI tool?

https://www.indiehackers.com/post/i-m-building-25-free-ai-tools-for-small-businesses-in-7-days-ea...
1•plakhlani2•56m ago•0 comments

Show HN: CardGroove – 52 on-line EMV tools, issuer, transactions simulator

https://cardgroove.polywickstudio.net/tools/
1•polywickstudio•57m ago•0 comments

Amiga Constellation

https://amiga.kexperiments.com
1•onename•58m ago•0 comments
Open in hackernews

Switch Lowering in GCC

https://xoranth.net/gcc-switch/
208•signa11•1d ago

Comments

arsalan17•1d ago
This one was interesting, especially its name :)
LarsKrimi•23h ago
> The switch in sparse_8 could be simplified by dividing x by eight before the jump. Interestingly, gcc doesn't find this simplification.

It could not because that would ensure that 7 values for each case would be handled by function calls instead of the default case - 0/8 is 0, but 3/8 is also 0

rep_lodsb•22h ago
All the values are divisible by 8, so it could do it like this:

    cmp  eax,40
    ja   <return 0>
    test eax,7
    jnz  <return 0>
    jmp  JumpTable[rax]
LarsKrimi•21h ago
Okay. Good point, that is quite a bit shorter than I first thought of

A rough benchmark of a version of that against the original shows it to be close to twice as fast for unpredictable input with GCC (4.5 ns vs 2.72 ns) on my old machine. With predictable input where x values often are the same the original version is quicker

    int sparse_8_jump(int x, int val) {
        unsigned int idx = (unsigned int)x >> 3;
        if (idx > 5)
            return 0;
        if (x & 7)
            return 0;
        
        switch (idx) {
            case 0:
                return f0(val);
            case 1:
                return f1(val);
            case 2:
                return f2(val);
            case 3:
                return f3(val);
            case 5:
                return f4(val);
            default:
                return 0;
        }
    }
ack_complete•15h ago
Think it could also be done with rotate, but unsure if it'd be faster:

  mov ecx, eax
  ror eax, 3
  cmp eax, 5
  ja  <return 0>
  jmp JumpTable[rcx]
Findecanor•22h ago
Reducing the range would have been useful to reduce the size of a jump table, but when you have a decision tree then it does not matter.

... unless the size of immediate parameters would have affected code size. In the example code however, all constants fit in an `imm8` parameter to `cmp`.

sylware•23h ago
In order to peak into hardware speculation/BTB, having a look atswitch lowering seems a good way. Big switches will go into serious convolution to please that hardware since by definition this is a source of a lot of branch mispredicitions.
ahartmetz•22h ago
There is surprisingly little about the proper feeding of advanced hardware in that code, two or three constants in cost calculations of which one or two are hardware-dependent.

It is still possible that a later pass arranges jump targets to avoid false sharing of their entries (addresses) in prediction mechanisms and such.

sylware•21h ago
Just look at the assembly output of significantly sized switch statements (with good random values): it's scary :)

Obvsiously engaging in pleasing as much as it can speculative/BTB hardware (to the cost of memory tables!)

ahartmetz•9h ago
I've seen it and it's not pretty, but hopefully fast. You kinda need to single-step it in assembly to be (somewhat) able to see what it does.
rurban•23h ago
What a shame for clang and gcc! They still don't implement perfect hashes for large sparse switch tables. I did that recently for my rcc C compiler, and it was just a single day of work. Esp. beneficial for unicode work. The LLVM patch was rejected a decade ago. Gcc has several unicode patches sitting in branches, which would also need that
tester756•23h ago
I'd bet because that's probably no better, that's it.

>The LLVM patch was rejected a decade ago

And what was the reasoning?

ahartmetz•22h ago
Also you could try again, many things may have changed since then including who maintains the code.
saagarjha•20h ago
It seems like someone did: https://github.com/llvm/llvm-project/issues/96971. However the performance implications of this was not well explored there
ahartmetz•18h ago
If the problem with the previous attempt was the same as with the more recent one, well duh. Just because this approach is new and clever doesn't mean it should always be used. It should be a last resort if cost estimates for other approaches are higher than some threshold where perfect hashing is likely to be cheaper.
tsukikage•23h ago
Why the indirection? - why not have the jump table reference f0..fX directly rather than jumping to a jump?
Findecanor•21h ago
That optimisation is simply missing.

Each `jmp` to f0..fX is an optimisation of a `call` and a `ret`, and probably done in a separate pass after the switch-case code has already been expanded.

The `mov edi, esi` at the top of the function is also an optimisation, most likely done during the register allocation pass. This was only possible because all functions take the same value in the same register. Otherwise, there would probably have been also a `mov` before each of the calls.

andikleen2•20h ago
gcc unfortunately cannot do this (and also not the related optimization of using word/byte offsets for the jump table, which LLVM can do) because it only has approximate estimation of code size. If it got the code size wrong it would be a mis-compilation. This is related to it not using an integrated assembler.
cowlevel•4h ago
Why does it need to know code size to put function addresses in the jump table?
Andi•22h ago
I remember having implemented similar things in JavaScript (by generating code), for immutable Maps and Sets - no significant performance gain in modern engines. For regular expressions of complex unicode ranges, the speedup was around 2x!
p-t•17h ago
I assume 34 in the compact_7() one was supposed to be 35, and edx was supposed to be used at some point in the bittest() one (unless i'm missing something lol)
erk__•14h ago
I once played around with having a very large switch statement (all mac address manufactors in one switch) and in LLVM it would compile fine without optimizations, but if I turned optimizations on it would just spend around half an hour compiling it. I think GCC did it faster, but its been some time ago since I did it. In the Rust crate that was the reasons for all this I just ended up doing perfect hashing which compiled much much faster.
zamalek•10h ago
> The compiler is able to implement them as a decision tree (even though maybe it shouldn't)

Sometimes a decision tree is definitely faster. When developing System.HashCode, I used a switch (which I think always compiles to a jump table in .Net - at least my case did back then). This was for the trailing non-block sized bytes, I think. It was either suggested, or I decided to try, a decision tree and it was significantly faster. This was _many_ years back, so I don't have the figures, but they can be better in some scenarios.

RossBencina•22h ago
Would like to hear more about the performance characteristics. Do you perfect hash to a contiguous range and then use a jump table, or do you perfect hash directly to relative offsets to basic blocks?
rurban•19h ago
See my docs. There are several cases: https://github.com/rurban/rcc/blob/main/docs/rcc.md#-o1-and-...
Sopel•18h ago
why is it so slow? it's around 50x slower than I would have expected for numbers https://github.com/ConstexprCore/perfect_hash
nh2•21h ago
Maybe LLVM doesn't have time for performance improvements due to still reading through 30000 open issues, which also include miscompilations leading to incorrect results at runtime?

For example, my bug report that `+= 2` is broken has not been acknowledged (read?) by anyone for 3 years:

    const size_t n = 13; // triggers the issue
    #pragma omp parallel for
      for (uint32_t i = 0; i < n; i += 2) {  // counts PAST 13!
https://github.com/llvm/llvm-project/issues/70687
rurban•20h ago
That's true. restrict is also still broken there. 30000 open issue is even worse than gcc
aw1621107•13h ago
> restrict is also still broken there.

That's a bit surprising to me given how heavily Rust uses the underlying mechanisms. Do you mean specifically how restrict is used in Clang or is there still something in LLVM that is broken?

rurban•12h ago
With certain short loops it's still broken, and rust had to workaround it. I've added an autoconf probe for it. https://github.com/rurban/autoconf-archive/blob/master/m4/ax...
aw1621107•9h ago
Hrm, interesting. First time I've heard of such a thing. Would have expected the Rust devs to have rolled back emitting noalias if it were still causing miscompiles. A quick glance through the bug tracker didn't turn up anything obvious, though I wouldn't be surprised if I just missed it.

For what it's worth, according to Godbolt the test program in your probe seems to work correctly for Clang 12.0.0 and later, which IIRC corresponds to when Rust (re-(re-?))enabled emitting noalias.

SubjectToChange•12h ago
Comparing all of the open issues of the llvm-project to GCC is obviously unfair. For instance over 500 issues are related to MLIR, 1700 issues are related to BOLT/lld/lldb, almost 3000 issues are related to the various clang tools that GCC does not offer (clang-tidy, clang-format, clang-doc, etc), another 442 issues are related to HLSL support, 281 issues belong to LLVM libc, various sanitizers have another 200 open issues, etc. Not to mention the extra compatibility clang offers, e.g. clang-cl, nor the fact that clang tries to be compatible with (undocumented) GCC idiosyncrasies.

Comparing open issues in the llvm-project repository is basically equivalent to comparing the open issues in GCC, binutils-gdb, glibc, and various utilities. Moreover, the LLVM project is intended as a compiler infrastructure/library framework, so it naturally has a larger surface area for bugs/issues relative to GCC. I mean, it’s not like GCC offers a generic API to interact with GIMPLE, or any other of its numerous internal representations.

rurban•4h ago
I have the numbers from my C-only testsuite. https://github.com/rurban/rcc#test-results

    gcc:   244 fails
    clang: 826 fails
Both should be zero. In all my compilers I'm thriving for zero.
stefan_•18h ago
#pragma omp

Ahh, there it is! This issue isn't being tended to because it will resolve itself with the imminent death of OpenMP.

jamiejquinn•15h ago
Now there's a bold statement! What makes you think OpenMP is on the way out?
SubjectToChange•8h ago
OpenMP is arguably in a better place today than it was ten years ago. For instance, MSVC added support for newer OpenMP standards and implementations now support genuine device offloading. Indeed, OpenMP is probably the most popular parallel programming interface for C/C++/Fortran in use today.

Sure, OpenMP is not a pretty API, nor is it likely to yield best-in-class performance. But OpenMP is highly portable, it enjoys first-class support GCC and LLVM/clang, and it’s very straightforward to get “good enough” performance with minimal code changes. Personally, I think it’s wonderful.

jcranmer•17h ago
Compiler optimizations are a trade-off between compile time, runtime, and code size, mediated by the availability of developer time.

Perfect hashing for switch tables is useful mostly for large, sparse switches, but hot large, sparse switches are rare, and the closest examples I can think of (e.g., parse tables) are themselves likely generated from other tools, which could itself be changed in lieu of the compiler. It really doesn't come across as a useful optimization to try implementing in a compiler.

bobmcnamara•17h ago
It comes up in emulators and VMs, and indeed those are often tool generated.
flohofwoe•15h ago
Hmm, IME at least in emulators the switch tables usually have enough 'structure' that GCC or Clang have no trouble turning them into jump tables.