News for hackers. Stuff that matters.
Re:Guide to Java Virtual Threads by cyberax on Wednesday March 15, 2023 @11:42PM (#35177884)
Async/await are also much slower than properly implemented (see: Golang) fibers.

Basically, with async/await you need to allocate on the heap frames for each level of the async/await call stack. You basically get a linked list of stack frames.

This is essentially isomorphic to segmented stacks that Go ditched in favor of resizable stacks, because segmented stacks kill performance if a tight loop just happens to cross a segment boundary.

Re:Guide to Java Virtual Threads by DeathArrow on Thursday March 16, 2023 @05:49AM (#35179961)
>Async/await are also much slower than properly implemented (see: Golang) fibers.

Are there any benchmarks to back that affirmation?

Re:Guide to Java Virtual Threads by cyberax on Thursday March 16, 2023 @07:22AM (#35180551)
Hm. I know this from my personal work, replacing Go code with an async/await code.

There's a bunch of benchmarks that compare C# async/await and Goroutines (e.g. https://alexyakunin.medium.com/go-vs-c-part-1-goroutines-vs-... ). Go still wins there, but they all miss the very important case of nested async/awaits.

These microbenchmarks also focus on looking at Go channels versus other synchronization methods, which in my experience is not that relevant (Go channels just suck).

I guess I'll need to write a blog post.

Re:Guide to Java Virtual Threads by DeathArrow on Thursday March 16, 2023 @03:00PM (#35186685)
Those benchmarks are really old, things can change quite fast when it comes to programming language implementations.
Re:Guide to Java Virtual Threads by cyberax on Thursday March 16, 2023 @08:20PM (#35190920)
I wrote a quick-and-dirty benchmark: https://blog.alex.net/benchmarking-go-and-c-async-await

Results: Go - 32ms, C# - 494ms. The difference also becomes bigger as you add more recursion levels.