frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

A SIMD coding challenge: First non-space character after newline

2•zokrezyl•1h ago
I’m working on a SIMD parser for a YAML-like language and ran into what feels like a good SIMD coding challenge.

The task is intentionally minimal:

detect newlines (\n)

for each newline, identify the first non-space character that follows

Scanning for newlines alone is trivial and runs at memory bandwidth. As soon as I add “find the first non-space after each newline,” throughput drops sharply.

There’s no branching, no backtracking, no variable-length tokens. In theory this should still be a linear, bandwidth-bound pass, but adding this second condition introduces a dependency I don’t know how to express efficiently in SIMD.

I’m interested in algorithmic / data-parallel approaches to this problem — not micro-optimizations. If you treat this as a SIMD coding challenge, what approach would you try?

Another formulation:

# Bit-Parallel Challenge: O(1) "First Set Bit After Each Set Bit"

Given two 64-bit masks `A` and `B`, count positions where `B[i]=1` and the nearest set bit in `A|B` before position `i` is in `A`.

Equivalently: for each segment between consecutive bits in `A`, does `B` have any bit set?

*Example:* `A=0b10010000`, `B=0b01100110` → answer is 2 (positions 1 and 5)

Newline scan alone: 90% memory bandwidth. Adding this drops to 50%.

Is there an O(1) bit-parallel solution using x86 BMI/AVX2, or is O(popcount(A)) the lower bound?

Comments

pestatije•58m ago
wheres the code?...have a look at codereview[5], the whole site is geared for this kind of challenges

[5] codereview.stackexchange.com

zokrezyl•48m ago
I do not have one "implementation" but have been trying with different approaches that all delivered under 50% of memory bandwith... I guess if anyone can purpose a solution should be from scratch... The problem is that all approaches I tried end up generating unpredictable branches that do not allow the CPU to optimally keep loading text from memory.
zokrezyl•38m ago
https://godbolt.org/z/3YMbaeEGh

One approach....

2026 Is the Year We Log Off

https://substack.com/home/post/p-182391335
2•seltzerboys•2m ago•0 comments

An initial analysis of the discovered Unix V4 tape

https://www.spinellis.gr/blog/20251223/?yc261223
1•DSpinellis•2m ago•0 comments

Ask HN: What is the Mt. Rushmore of desktop applications?

1•exogeny•3m ago•0 comments

Urban wild bees act as 'microbial sensors' of city health

https://www.todayinagriculture.com/article/877465580-urban-wild-bees-act-as-microbial-sensors-of-...
1•geox•4m ago•0 comments

Anthropic Skills Can Be Programmatically Optimized (Using DSPy)

https://instavm.io/blog/anthropic-skills-can-be-optimized-using-dspy
1•mkagenius•4m ago•0 comments

Eagle – Organizing design files has never been easier

https://eagle.cool/
1•eustoria•4m ago•0 comments

Japanese shops halt desktop PC orders until 2026 as memory shortage intensifies

https://www.tomshardware.com/desktops/pc-building/japanese-shops-halt-desktop-pc-orders-until-202...
1•speckx•6m ago•0 comments

I used RL fine-tuning to make an LLM generate ugly and unpythonic FizzBuzz code

https://seantey.github.io/sloppy-fizzbuzz-blog/sloppy_fizzbuzz_blog.html
1•seanrrr•7m ago•1 comments

Form Is What Survives

https://udara.io/constraint-theory/
2•udara•9m ago•0 comments

Homebrew still can't install specific version of formula

https://stackoverflow.com/questions/3987683/homebrew-install-specific-version-of-formula
1•behnamoh•10m ago•1 comments

A Physical Meme Terminal for Distributed Teams

https://blog.golioth.io/a-physical-meme-terminal-for-distributed-teams/
3•ChrisGammell•10m ago•0 comments

Garmin autopilot lands aircraft without human assistance

https://www.heise.de/en/news/Emergency-in-Colorado-Garmin-autopilot-lands-aircraft-without-human-...
1•sokols•10m ago•0 comments

Addiction, ADHD, Discipline and Obsession

https://olshansky.info/thoughts/2025-12-23-addiction-adhd-discipline-and-obsession
1•Olshansky•12m ago•0 comments

PlayStation Network account recovery allows 2FA bypass

https://twitter.com/i/status/2003458551952638279
1•hocuspocus•12m ago•0 comments

The Stream Animals Thriving After a Megafire

https://nautil.us/the-stream-animals-thriving-after-a-megafire-1256732/
1•fleahunter•13m ago•0 comments

Amnezia – Self-Hosted VPN

https://amnezia.org/self-hosted
2•eustoria•14m ago•0 comments

Counting blessings versus burdens: an experimental investigation of gratitude

https://pubmed.ncbi.nlm.nih.gov/12585811/
1•RickJWagner•15m ago•0 comments

She made biggest discovery of New Life Forms in 50 years [video]

https://www.youtube.com/watch?v=sB7y7pSbSCQ
1•stevenjgarner•16m ago•1 comments

The Frontier Is Open. Are You Sophisticated Enough to Compete?

https://nivria.ai/thoughts/the-frontier-is-open-are-you-sophisticated-enough-to-compete
1•jniv•17m ago•0 comments

Narrative Decomposition and Resonance

https://github.com/totiks2012/The-Alchemist-of-Narratives
1•totiks2025•20m ago•1 comments

Colonizing Mars: Challenges and Solutions

https://www.youtube.com/watch?v=eFoUulGMhwM
1•d_silin•21m ago•0 comments

Show HN: FormAIt – Free, private offline note formatting using LLMs

https://blazingbanana.com/apps/formait/
1•blazingbanana•21m ago•1 comments

None of Your Beeswax

https://hollisrobbinsanecdotal.substack.com/p/none-of-your-beeswax
1•HR01•22m ago•0 comments

AI startup is extending an olive branch between humans and machines

https://www.fastcompany.com/91464353/olive-is-bill-nguyen-voice-ai-education
1•ohjeez•23m ago•0 comments

We replaced H.264 streaming with JPEG screenshots (and it worked better)

https://blog.helix.ml/p/we-mass-deployed-15-year-old-screen
3•quesobob•24m ago•0 comments

I've Made Tinder for Cities

1•nonmaskable•25m ago•0 comments

Minimizing Hyperbolic Embedding Distortion with LLM-Guided Hierarchy Structuring

https://arxiv.org/abs/2511.20679
1•PaulHoule•25m ago•0 comments

Teach Your Agents What You Know

https://kevins981.github.io/blogs/teachagent_part1.html
2•kevinsong981•25m ago•1 comments

Greta Thunberg has been arrested for terrorism in London for holding a sign

https://old.reddit.com/r/LateStageCapitalism/comments/1ptwgxi/greta_thunberg_has_been_arrested_on...
8•testing22321•27m ago•1 comments

Imagebyqwen.com – Fast AI text-to-photo using Qwen

https://imagebyqwen.com
1•mariolattik•27m ago•1 comments