HAProxy - Load balancer
Find a file
Willy Tarreau 55744154b4 BUG/MINOR: poller: fix wait time calculation that is always 1 extra ms
In 1.3.11, 19 years ago, commit bdefc513a0 ("[BUG] fix null timeouts in
*poll-based pollers") addressed an issue where some wakeup times could
sometimes be rounded to less than one millisecond (by then they were
calculated on timeval), and would make the poller wake up too early and
loop with a timeout of zero. The solution used by then consisted in
always adding 1 to the wait delay so that poll() was never called with
a null timeout.

Nowadays our internal wakeup delays are in milliseconds so we cannot wake
too early, all the timeout calculation was moved to compute_poll_timeout()
which has a specific check for expired next wakeup event, so we cannot
even have a null timeout as a result of a real delay calculation by
accident. Yet, it's clearly visible with strace thats a task created
with an interval of 10ms results in a poll timeout of 11ms, causing some
small time drift in periodic wakeups.

Let's just now drop this "+1" which is no longer needed nor relevant and
only causes wrong delays to be calculated. Now creating a time-printing
task results in correct delays passed to poll() and measured intervals
around:
  - ~10.3ms interval for 10ms
  - ~100.5ms for 100ms
  - ~1001ms for 1000ms

E.g:

  $ socat - /tmp/sock1 <<< "expert-mode on;debug dev sched task print=1 inter=10 count=1"
  (...)

  17:58:05.191885 clock_gettime(CLOCK_THREAD_CPUTIME_ID, {tv_sec=0, tv_nsec=44590744}) = 0
  17:58:05.191919 epoll_wait(4, [], 200, 10) = 0
  17:58:05.202215 clock_gettime(CLOCK_THREAD_CPUTIME_ID, {tv_sec=0, tv_nsec=44601494}) = 0
  17:58:05.202237 write(1, "task 0x3aeeb080: time_ms=3553"..., 42task 0x3aeeb080: time_ms=355304053.757383
  ) = 42
  17:58:05.202253 clock_gettime(CLOCK_THREAD_CPUTIME_ID, {tv_sec=0, tv_nsec=44610199}) = 0
  17:58:05.202265 epoll_wait(4, [], 200, 10) = 0
  17:58:05.212579 clock_gettime(CLOCK_THREAD_CPUTIME_ID, {tv_sec=0, tv_nsec=44631754}) = 0
  17:58:05.212639 write(1, "task 0x3aeeb080: time_ms=3553"..., 42task 0x3aeeb080: time_ms=355304064.157626
  ) = 42

These delays with longer sleeps are entirely on the system side, most
likely due to the CPU switching to low-power for such long delays (tests
run on a laptop).

There is no reason to backport this fix, though it shouldn't hurt either.
2026-06-24 18:01:33 +02:00
.github CI: github: run illumos job weekly on Mondays at 03:00 instead of monthly 2026-06-03 13:22:04 +02:00
addons MINOR: addons/51degrees: handle memory allocation failures 2026-05-31 10:26:41 +02:00
admin CLEANUP: admin/halog: improve handling of memory allocation errors 2026-05-31 10:30:00 +02:00
dev DEV: patchbot: prepare for new version 3.5-dev 2026-06-03 14:56:22 +02:00
doc DOC: lua: remove incorrect init tags 2026-06-24 07:03:30 +02:00
examples EXAMPLES: lua/acme: fix acme-gandi-livedns.lua configuration example 2026-06-15 13:50:22 +02:00
include MEDIUM: httpclient/lua: allow multiple requests from a single core.httpclient() instance 2026-06-14 01:49:54 +02:00
reg-tests REGTESTS: quic: test H3 request without content-length 2026-06-24 08:53:04 +02:00
scripts SCRIPTS: announce-release: add a link to the OpenTelemetry filter 2026-05-08 12:05:09 +02:00
src BUG/MINOR: poller: fix wait time calculation that is always 1 extra ms 2026-06-24 18:01:33 +02:00
tests TESTS: quic: add unit-tests for QUIC TX part 2025-09-08 14:49:03 +02:00
.gitattributes MINOR: Configure the cpp userdiff driver for *.[ch] in .gitattributes 2021-02-22 18:17:57 +01:00
.gitignore MINOR: tevt/dev: Add term_events tool 2025-01-31 10:41:50 +01:00
.mailmap DOC: update Tim's address in .mailmap 2021-09-16 09:14:14 +02:00
.travis.yml MEDIUM: mworker: remove USE_SYSTEMD requirement for -Ws 2024-11-20 12:07:38 +01:00
BRANCHES CLEANUP: tree-wide: fix typos in user-invisible files 2026-05-13 17:03:48 +02:00
BSDmakefile BUILD: makefile: commit the tiny FreeBSD makefile stub 2023-05-24 17:17:36 +02:00
CHANGELOG [RELEASE] Released version 3.5-dev0 2026-06-03 15:26:45 +02:00
CONTRIBUTING CLEANUP: assorted typo fixes in the code and comments 2025-04-02 11:12:20 +02:00
INSTALL MINOR: version: mention that it's development again 2026-06-03 15:25:53 +02:00
LICENSE LICENSE: add licence exception for OpenSSL 2012-09-07 13:52:26 +02:00
MAINTAINERS MAJOR: spoe: Let the SPOE back into the game 2024-05-22 09:04:38 +02:00
Makefile BUILD: makefile: fix build error with GNU make 4.2.1 and /bin/dash 2026-06-03 12:04:21 +02:00
README.md CI: github: replace cirrus by a vmactions/freebsd-vm job 2026-06-03 11:20:31 +02:00
SUBVERS BUILD: use format tags in VERDATE and SUBVERS files 2013-12-10 11:22:49 +01:00
VERDATE [RELEASE] Released version 3.4.0 2026-06-03 15:01:51 +02:00
VERSION [RELEASE] Released version 3.5-dev0 2026-06-03 15:26:45 +02:00

HAProxy

AWS-LC Illumos NetBSD CrossCompile FreeBSD VTest

HAProxy logo

HAProxy is a free, very fast and reliable reverse-proxy offering high availability, load balancing, and proxying for TCP and HTTP-based applications.

Installation

The INSTALL file describes how to build HAProxy. A list of packages is also available on the wiki.

Getting help

The discourse and the mailing-list are available for questions or configuration assistance. You can also use the slack or IRC channel. Please don't use the issue tracker for these.

The issue tracker is only for bug reports or feature requests.

Documentation

The HAProxy documentation has been split into a number of different files for ease of use. It is available in text format as well as HTML. The wiki is also meant to replace the old architecture guide.

Please refer to the following files depending on what you're looking for:

  • INSTALL for instructions on how to build and install HAProxy
  • BRANCHES to understand the project's life cycle and what version to use
  • LICENSE for the project's license
  • CONTRIBUTING for the process to follow to submit contributions

The more detailed documentation is located into the doc/ directory:

License

HAProxy is licensed under GPL 2 or any later version, the headers under LGPL 2.1. See the LICENSE file for a more detailed explanation.