Luke Lau

@lukel97.bsky.social

LLVM at Igalia

Had a great Igalia week last week, @lukel97.bsky.social, Cathie and I fed other Igalians some Zongzi, told them the story of the Dragon Boat Festival and taught them how to write Chinese words related to the festival! (Forgot to take a picture of our table but I have a picture of preps ^^)

Preparing for the Chinese writing activity

One of the nice parts of #llvm is that often times you'll find yourself needing to do some sort of non-trivial analysis, but usually there's already a pass for it. Here's how you can reuse a block frequency analysis to make a chess engine 7% faster on #riscv: lukelau.me/2026/01/26/c...

Closing the gap, part 2: Probability and profitability

Welcome back to the second post in this series looking at how we can improve the performance of RISC-V code from LLVM.

lukelau.me

After two months of chasing, finally found out what's happening behind this mysterious startup time regression on macOS from Node.js v20.x - it's missing -fvisibility=hidden 😅 (I guess that's what happens when the build configs become dusty enough) github.com/nodejs/node/...

build: build v8 with -fvisibility=hidden on macOS by joyeecheung · Pull Request #56275 · nodejs/node

V8 should be built with -fvisibility=hidden, otherwise the resulting binary would contain unnecessary symbols. In particular, on macOS, this leads to 5000+ weak symbols resolved at runtime, leading...

github.com

Trying to find the slowest possible RISC-V instruction. This single vlse8.v with a stride of 65536 bytes takes 66 million cycles on a Banana Pi F3. That's 0.04 seconds @1.6GHz #risc-v

A screenshot of a terminal:
luke@bananapif3:~/slowest-instr$ cat main.S
	.section .rodata
str:	.asciz "Cycles: %d\n"
foo:	.zero 256 * STRIDE
	.section .text
	.global main

main:
	addi	sp, sp, -8
	sd	ra, 0(sp)

	rdcycle	s1
	rdcycle s2
	sub	s3, s2, s1 	# rdcycle overhead

	la	a0, foo
	li	a1, STRIDE
	vsetvli t0, zero, e8, m8, tu, mu
	rdcycle s1
	vlse8.v	v8, (a0), a1
	rdcycle	s2

	sub	s1, s2, s1
	sub	s1, s1, s3
	la	a0, str
	mv	a1, s1
	call	printf

	ld	ra, 0(sp)
	addi	sp, sp, 8
	ret
luke@bananapif3:~/slowest-instr$ clang main.S -DSTRIDE=65536 -march=rv64gv 
luke@bananapif3:~/slowest-instr$ perf stat -e cycles:u ./a.out 
Cycles: 66640979

 Performance counter stats for './a.out':

        78,064,581      cycles:u                                                           

       0.049648957 seconds time elapsed

       0.000000000 seconds user
       0.049907000 seconds sys