First post, by st31276a
Yes the title sounds clickbaitey, but this is absolutely insane.
A better title might have been "Well written code meets well trained LLM" or "How to get MariaDB 5.5.68 going on Red Hat 8.0 Psyche".
At the moment, I am busy with my cC0-stepping Pentium 120 again, for which I got the L2 cache going after the cache has not been working for many years: GMB-P54SPV L2 cache working after 21 years...
I am about to start writing a program that will use a JSON-RPC based database backend; I want to develop the backend on this computer. A slow computer for development has certain advantages, as it shows me what is how slow the moment it happens, so that I can pay attention to it and make better plans. It's not quite the same vibe as profiling/measuring the code in other ways.
I decided to go for the latest version in the MariaDB 5.5 release, as it supports all the features I need.
While compiling, I have the luxury to generate an optimized i586 binary. I opted to specify to optimize for size (-DCMAKE_BUILD_TYPE=MinSizeRel) as well, as the program is going to be huge and memory performance relative to cpu performance on this system is slow.
I was amazed to see how well written the MariaDB source code is, a program released in 2020 compiles mostly clean on 2003 era compiler and libraries (gcc 3.2, glibc 2.3.2) for the exception of a few caveats.
1. mysys/my_getsystime.c
On line 50, we check with #ifdef if HAVE_CLOCK_GETTIME is defined, which it is on this system. The code then wants to call clock_gettime() with CLOCKSOURCE_MONOTONIC, which does not exist on this system and causes the compiler to fail. Since there is a fallback at the end to use gettimeofday() which is absolutely good enough for this purpose, I just broke the thing #ifdef looks for on line 50 so that it can skip this broken part and compile the fallback.
2. storage/sphinx/ha_sphinx.cc
A function that always returns 0 has been wrapped in void ( ) on line 700 - probably to suppress compiler warnings about not using a return value. This compiler doesn't like that. Replacing "void ( )" with something like "int _temp = "fixes the issue.
3. plugin/handler_socket/handlersocket/hstcpsvr_worker.cpp
This file has a linux implementation to manage network sockets using epoll, which kernel 2.4.20 and glibc 2.3 knows nothing about - as it is a kernel 2.6 feature. Luckily there is also a generic implementation available that uses poll, but it is #ifdef'ed out - the #ifdef __linux__ on line 19, just above #include <sys/epoll.h> includes the epoll part and excludes the poll part. A well aimed #undef __linux__ just above it fixes the problem.
4. libmysql/libmysql_versions.ld
The linker does not understand this file. However, versioning library versions is not something I am interested in here and can do without. The cmake option -DDISABLE_LIBMYSQLCLIENT_SYMBOL_VERSIONING=TRUE bypasses this problem.
5. sql/threadpool_unix.cc
The very last file in the compile list announced the end of the road. The thing that manages the worker threads uses epoll only, there is even a comment in the file stating that no poll implementation is available. This must have been written well after kernel 2.6 became mainstream. The only solution is to actually write the poll based implementation for this to work on RedHat 8.0, all 1600-ish lines of it...
At this point I said fuck it, let's try some vibecoding to see if it lives up to the hype. I opened a tab of Anthropic's Claude, attached threadpool_unix.cc and typed convert the attached file that uses epoll to use poll instead, or something like that. A one-liner.
It churned for a couple of minutes and generated the file I attached to this post. I gave it a once-over and it looked rather neat, could see nothing wrong with it. I dropped it in and started cmake up again and it compiled without error or warning. I installed and started mariadb and it handles the work dispatching from more than one client connection as expected - it works!
I have MariaDB 5.5.68 running on Red Hat 8.0 on an i586 - the only one in the world.
I attach the solution here, in case there is somebody out there who wishes to join in my joy. Had to zip it as it keeps saying it is not an allowed file type.
I am really surprised how well the Sonnet 4 language model worked with the source file. It does not compile, it only manipulates language symbols. Having a well written file to work from and being trained on programming stuff in general yielded unbelievable results.
Currently the P1 is compiling php 5.5, as that is the oldest version to support mysql transactions and I want to use those for certain operations. So far so good...