You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "nickva (via GitHub)" <gi...@apache.org> on 2026/02/17 23:29:33 UTC
[PR] Switch to hibernate_after [couchdb]
nickva opened a new pull request, #5890:
URL: https://github.com/apache/couchdb/pull/5890
When debugging processes getting stuck in hibernation bug [1] a few benchmarks showed that hibernation can be pretty expensive. I saw 20% or so reduction in latency in couch_work_queue if we hibernate after every single item insertion.
Erlang documents warn about this [2]:
> Use this feature with care, as hibernation implies at least two garbage collections (when hibernating and shortly after waking up) and is not something you want to do between each call to a busy server.
In a few places like the `couch_work_queue` and `couch_db_updater` we did exactly that [3]. However, since we added that more Erlang/OTP implemented a new `gen_server` option - `{hibernate_after, Timeout}`. It will trigger hibernation after an idle time. That seems ideal for us - it keeps expensive hibernation out of the main data path, as docs warn us about, but once the server goes idle we still get to run it to dereference any ref binaries.
Since we encountered the recent hibernation bug [1] also add an option to disable it altogether, just to have a way to mitigate the issue when running on OTP 27 and 28 before the fix is out.
As a separate commit also fix `get_integer_or_infinity/3` to handle an explicitly configured "infinity" value.
[1] https://github.com/erlang/otp/issues/10651
[2] https://www.erlang.org/doc/apps/stdlib/gen_server.html
[3] https://github.com/apache/couchdb/commit/d9eb87f60ac8328afcca25cf6c7aae53b395b089
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Switch to hibernate_after [couchdb]
Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva commented on PR #5890:
URL: https://github.com/apache/couchdb/pull/5890#issuecomment-3943000500
At @janl's suggestion ran an bulk_docs with and without this PR
Used a k6 script https://gist.github.com/nickva/88564cf77763b2b000bd9563406f03dc
```BENCH_Q=16 BENCH_SCENARIOS=bulk_docs BENCH_BULK_DOCS_RATE=50 BENCH_DURATION=3m k6 run k6_couchdb_constant_arrival.js```
On an 8 core i5-8365U intel laptop with Ubuntu and Erlang 27.3.4.7. Ran the benchmark 3 times with before the PR main and after the PR.
Main before the PR:
```
{ name:bulk_docs }...........: avg=29.96ms min=9.21ms med=19.89ms max=294.76ms p(90)=50.89ms p(95)=84.26ms
{ name:bulk_docs }...........: avg=25.9ms min=9.72ms med=22.48ms max=122.82ms p(90)=39.45ms p(95)=49.31ms
{ name:bulk_docs }...........: avg=24.52ms min=9.9ms med=21.36ms max=116.94ms p(90)=37.19ms p(95)=45.9ms
```
Main with the PR
```
{ name:bulk_docs }...........: avg=21.54ms min=9.44ms med=19.12ms max=133.65ms p(90)=30.82ms p(95)=38.8ms
{ name:bulk_docs }...........: avg=21.96ms min=9.72ms med=19.52ms max=128.56ms p(90)=31.65ms p(95)=39.28ms
{ name:bulk_docs }...........: avg=22.54ms min=9.32ms med=19.97ms max=93.85ms p(90)=32.67ms p(95)=40.78ms
```
Average, p90 and p95 looks a bit better but overall it's not a large difference. It's probably dominated by disk IO times.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Switch to hibernate_after [couchdb]
Posted by "nickva (via GitHub)" <gi...@apache.org>.
nickva merged PR #5890:
URL: https://github.com/apache/couchdb/pull/5890
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org