Hacker Newsnew | past | comments | ask | show | jobs | submit | 0xjnml's commentslogin

> If you really want an arena like behavior you could allocate a byte slice and use unsafe to cast it to literally any type.

Only if the type is not a pointer per se or does not contain any inner pointers.

Otherwise the garbage collector will bite you hard.


Types with inner pointers add difficulty to be sure, but it’s still possible to use them with this pattern. You have to make sure of three things to do so: 1) no pointers outside of the backing memory; 2) an explicit “clear()” function that manually nulls out inner pointers in the stored object (even inner pointers to other things in the backing slice); 3) clear() is called for all such objects that were ever stored before the backing slice is dropped and before those objects are garbage collected.


YouTube is one such.


Maintainer here, AMA.


Sorry late response/question.

Do you have a good source of documentation regarding QBE?

I tried to use it in the past and it was a PITA as I was left basically helpless. I don't do the discord thing.


Documentation for the QBE IL is here: https://c9x.me/compile/doc/il.html

I find it quite usable.


You took the wrong exit, sir. This is the right way: https://en.wikipedia.org/wiki/Request_for_Comments


Yes! I want to publish there too. But I wanted to get some early feedback from people!


Also, can you give me a link to the entry point for the RFC submission, my good sir?


It seems you're using some old Go package versions for your benchmarks.

See https://pkg.go.dev/modernc.org/sqlite-bench#readme-tl-dr-sco... for the numbers using the more recent versions.


(I'm the original author but not the OP)

It was done in september of '24 with go 1.23.1 and the most recent (at the time) versions of sqlite libraries, as stated.

The page you linked compares golang bindings against each other, not C against golang like my test did


> The page you linked compares golang bindings against each other, not C against golang like my test did

No one disputed that. But it follows that your benchmarks are comparing C to [some very] outdated versions of Go packages. Which is what I tried to point out.


It is transpiled from C to Go, meaning 90+% of the effort is mechanized.

Ad performance. In some micro benchmarks the Go version is ~4x slower: https://gitlab.com/cznic/libquickjs/-/blob/675ee343753c42341...

However, it's already ~25% faster, in a different benchmark, than another Go JS VM written from scratch: https://pkg.go.dev/modernc.org/quickjs@v0.14.0#hdr-Performan...

I am currently looking around if it can be improved more and there are some ideas to try out.


That's an interesting result, thanks. I just calculated the geomean of all relations, which is 4.32. The original C code doesn't seem to make use of GCC-specific tricks such as computed gotos, so your experiment essentially demonstrates the optimization efficiency of the Go compiler compared to the C compiler. It would be interesting to use a more established benchmark suite like Are-we-fast-yet, which has a JS implementation.


go.mod files have no dependencies, so neither they can have circular dependencies.

go.mod files just list the dependencies of their respective package.


- Turn Tcl code into standalone executables

- Easily cross-compile these executables for other systems


Go slice is neither of that, it is a window into an array.


Time spent writing code is IMO the smallest part of software engineering.

Optimizations give better results when care is taken first about the most costly parts.


That's the stuff I rather spend my time on when making money with software; all the other parts. One exists with the other.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: