Please do not require AVX support for your software
Intro
Hey! I'm Pavel from London, I'm CTO of FastNetMon and we run DDoS attack detection with on premise installations in 146 countries.
This post was inspired by GitHub conversation which was triggered by Clickhouse's team decision to start asking for CPU feature called AVX for all new installations.
Fortunately, it was rolled back after customer's complains.
It's not a first time I noticed such approach. Last month we tried to migrate FastNetMon Advanced to latest MongoDB and we discovered their demand for AVX too. MongoDB starting from 5.0 requires support for AVX.
It's deeply disappointing as we have plenty of customers without AVX and for now we have to use MongoDB 4.4 but after EOL we will need to decide what to do.
What's wrong with AVX?
It's pretty decent technology which may offer some reasonable performance boost in some subset of applications:
- Cryptography
- AI workloads
- Memory copy
Is it silver bullet which will speed up your software automatically?
Definitely not.
It's an extremely complicated to write software which can use these modern capabilities efficiently and performance gain will be in range of 5-15% if you're successful in that field.
Developers behind Linux Kernel and projects like OpenSSL definitely can do and they have support for such capabilities.
I would like to highlight fact that nothing wrong in particular with AVX but AVX 2 and AVX 512 is a completely different story and I recommend checking it with Google.
Is it 11 year old?
Yes, it's. It was introduced in 2011 in Sandy Bridge.
Why not everyone has it?
There are multiple reasons behind lack of AVX and I would like to cover each in details:
- Old server CPUs
- Virtualisation
- Customer grade CPUs
Old server CPUs
I want to highlight that these so called old CPUs are perfectly fit to run modern workloads. CPU development is going over path of adding more cores but single core performance is not growing significantly for last decade.
I would like to add this graph by Chuck Moore of AMD to prove my point:
As you may see just banning 10+ year old CPUs which are perfectly fit to run any modern workload due to lack of quite niche feature as AVX is not something which does make sense.
These CPUs may be energy inefficient but they're definitely not slow.
Virtualisation
I started my professional career when it was hot buzzword around.
It's still extremely tricky to implement properly and we have two reasons which may lead to lack of AVX on virtualisation platforms:
- Mistake / laziness with CPU profile selection during VM provision phase. Some virtualisation platforms have defaults which disable SSE 4.2 and AVX.
- Live migration. To use such modern feature as live migration for your private or public cloud you need to maintain exactly same subset of CPU features for all your servers. Otherwise it will lead to issues like this. So even if you have 1000 machines with AVX in your cloud deployment and 20 without it then AVX must be disabled for all of them. Otherwise it will lead to issues and inability to use live migration to / from these machines.
Can you do something about?
Sure, please review your cloud configuration and check that AVX and SSE42 are enabled for your VMs by default unless you have reasons not to.
Customer grade CPUs
I mostly covered issues with AVX in context of server CPUs but so many customer grade CPU will definitely lack of AVX and it will effectively ban their owners from playing with your software on their developer machines.
And guess what? These people may be your customers. In case of lack of AVX on their machines you effectively drop them and reduce your potential revenue.
It will make things way worse in developing countries which just cannot afford modern AVX capable equipment even for their servers.
What is the solution?
For compiled software you may consider shipping different versions of binaries of your product with SSE42, AVX, AVX2, AVX512 support. You may ship them in different packages and select package name on installation phase.
You may even create simple wrapper compiled without any fancy CPU flags which just checks for available CPU flags and selects correct binary from multiple options.
I can recommend reading more about approaches to accomplish this goal properly. It's called CPU dispatching and Google will help you.
Do not require AVX
Please do not require such modern CPU features. Do not expect that all people run latest generation of hardware and can afford to do upgrade. Considering current global chip shortage it makes even more sense. For many hardware platforms waiting time exceeds years. Even if your customer has money and ability to make upgrade they may need years to finish it.
Our World has many extremely serious equality issues. Please do not add one more.
Thank you!