mirror of
https://github.com/haproxy/haproxy.git
synced 2026-03-05 14:50:45 -05:00
HAProxy - Load balancer
Sometimes we need to be able to signal one thread among a mask, without caring much about which bit will be picked. At the moment we use ffsl() for this but this sometimes results in imbalance at certain specific places where the same first thread in a set is always the same one that is selected. Another approach would consist in using the rank finding function but it requires a popcount and a setup phase, and possibly a modulo operation depending on the popcount, which starts to be very expensive. Here we take a different approach. The idea is an input bit value is passed, from 0 to LONGBITS-1, and that as much as possible we try to pick the bit matching it if it is set. Otherwise we look at a mirror position based on a decreasing power of two, and jump to the side that still has bits left. In 6 iterations it ends up spotting one bit among 64 and the operations are very cheap and optimizable. This method has the benefit that we don't care where the holes are located in the mask, thus it shows a good distribution of output bits based on the input ones. A long-time test shows an average of 16 cycles, or ~4ns per lookup at 3.8 GHz, which is about twice as fast as using the rank finding function. Just like for that one, the code was stored into tools.c since we don't have a C file for intops. |
||
|---|---|---|
| .github | ||
| addons | ||
| admin | ||
| dev | ||
| doc | ||
| examples | ||
| include | ||
| reg-tests | ||
| scripts | ||
| src | ||
| tests | ||
| .cirrus.yml | ||
| .gitattributes | ||
| .gitignore | ||
| .mailmap | ||
| .travis.yml | ||
| BRANCHES | ||
| CHANGELOG | ||
| CONTRIBUTING | ||
| INSTALL | ||
| LICENSE | ||
| MAINTAINERS | ||
| Makefile | ||
| README | ||
| SUBVERS | ||
| VERDATE | ||
| VERSION | ||
The HAProxy documentation has been split into a number of different files for ease of use. 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 : - doc/intro.txt for a quick introduction on HAProxy - doc/configuration.txt for the configuration's reference manual - doc/lua.txt for the Lua's reference manual - doc/SPOE.txt for how to use the SPOE engine - doc/network-namespaces.txt for how to use network namespaces under Linux - doc/management.txt for the management guide - doc/regression-testing.txt for how to use the regression testing suite - doc/peers.txt for the peers protocol reference - doc/coding-style.txt for how to adopt HAProxy's coding style - doc/internals for developer-specific documentation (not all up to date)