Hacker News new | past | comments | ask | show | jobs | submit login

Does anyone have an idea of the performance impact of calling back and forth to Go from sqlite rather than C?




Thanks for the rabbit hole. The faq linked golang CGo issue [0] features `mattn/go-sqlite` too. It appears there is a particular impact for repeatedly calling any C that takes longer than ~20µs but that issue doesn't really try to quantify general CGo impact.

In my entirely unscientific go test on 100000 incremented integers, it's look like "some" impact.

    inserts took:     891.307359ms
    count: 100000       6.76659ms   SELECT count(integer) from itable
    lower one: 1111    31.708µs     SELECT lower(integer || integer || integer || integer) from itable
    repeat one: 1111   64.275µs     SELECT repeat(integer, 4) from itable
    lower4:           149.027976ms  SELECT lower(integer || integer || integer || integer) from itable
    repeat4:          507.223713ms  SELECT repeat(integer, 4) from itable
    concat4:          132.156995ms  SELECT integer || integer || integer || integer from itable

It probably doesn't matter a huge amount for the ad hoc `dsq` use, having them available is better than not.

[0]: https://github.com/golang/go/issues/19574




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: