Skip to main content
  1. Posts/

c2k24 - OpenBSD Hackathon Prague 2024

·2395 words·12 mins· loading · loading ·
Rafael Sadowski
Author
Rafael Sadowski
Shut up and hack
Table of Contents

This Is The Way
#

Every year, I try to make it possible for myself to attend an OpenBSD hackathon. This year, it was quite easy: Prague isn’t far from Nuremberg, so I decided to make the trip by bike. Planning the journey? No time for that—life is just too busy in the summer! I wanted it to be a challenge anyway.

Unfortunately, the day before I was set to leave, I realized my gravel bike had an issue with the wheel. So, I grabbed my (old) SCOTT mountain bike and got it ready for the trip. The hackathon was set to start on Monday, so I had 3–4 days to get there. I mapped out the route for the first day and planned to take things day by day, adjusting based on the weather and how I was feeling.

Day 1
#

Komoot - 104 km 🏁 👍 1.000 m 👎 890 m

The workday flew by quickly, as usual on a Friday morning, filled with back-to-back calls. I made my go-to healthy (and delicious) muesli as an energy boost for the day’s stage and said goodbye to my wife before heading towards the Czech border. The goal for the day: Weiden in der Oberpfalz, hopefully in time for the Germany vs. Spain Euro match. I’m not a huge football fan, but when the Euros are hosted in your own country, it feels like a must-watch event.

With that in mind, I set off at full speed out of Nuremberg, following a scenic route through the countryside. At every stop, I checked emails to stay on top of any important work matters, but luckily, there weren’t many. The timeline was tight, especially when the heat picked up around 3 PM. So, I grabbed a cold drink whenever I could and pushed on hard.

I made it to the hotel just after the kickoff. After checking in, I saw a group of people in the lobby watching the game on TV. I quickly brought my bike up to my room (no objections from reception—nice!). Then I dashed to the restaurant, ordered a delicious Buddha Bowl and an appetizer, and settled down in the lobby with my food and a non-alcoholic beer to catch the second half.

Well, after the game, I was feeling a bit down. Back in my room, did I boot up OpenBSD? No. Did I think about the hackathon? Not really. But I did plan and book the route and hotel for the next day.

Day 2
#

Komoot - 117 km 🏁 👍 1.670 m 👎 1.610 m

Day two started with perfect weather, and by 8 AM, the temperatures were already high. I decided to stop by a bakery and another store to grab some sunscreen—definitely the best decision I made that morning. After taking a quick look around Weiden in der Oberpfalz and having a light breakfast, I set off on what turned out to be the toughest stage of the journey. Just 5 kilometers in, I was met with a steep 650-meter climb. By the time I reached the highest point at the border, I was drenched in sweat. But the route promised an incredible downhill ride, which I was really looking forward to.

To my disappointment, there was no border control or officials—just a few signs that I quickly took photos of before continuing into the Czech Republic. The descent was fantastic! A beautiful, dense, and healthy forest stretched out before me. I couldn’t help but think how glad I was to have my mountain bike instead of my gravel bike—there were far too many large stones to navigate. I flew through the first few kilometers in the Czech Republic at full speed.

The route passed through several small villages, where I hoped to restock my supplies. But I had no luck—they were all ghost towns. I had to adjust my plan and find a small town instead. Tachov came to the rescue, with a Billa supermarket providing the perfect lunch by a lake. After refueling, I continued towards the Slavkov Forest (Chráněná krajinná oblast Slavkovský les). I was excited because I’d heard great things about it, but then came the real highlight of the day: riding through Mariánské Lázně. Wow, it was stunning! That brief but beautiful visit gave me a second wind, which I desperately needed as I was starting to struggle with the heat and the climbs.

After Mariánské Lázně, I cycled through more beautiful forests, which provided much-needed shade and relief from the heat. But as the evening approached, my energy was running low, and I was starting to feel it. Still, I pressed on.

Then, things got chaotic. Deep in a dense forest, the path started to disappear. I was relying entirely on GPS. Suddenly, a huge fallen tree blocked the way. After a quick stop to assess the situation, I was swarmed by at least 20 mosquitos. I rushed to get the bike on my back and climb over the tree, pulling out every ounce of energy to escape both the incline and the bugs. When I reached the top, another surprise awaited me—no path, even though my route said there should be one. After an extra 5 kilometers of detouring, I finally reached the last climb. I somehow managed to push through it, but by the time I reached the top, I was completely drained.

I thought the final descent into Karlovy Vary (Carlsbad) would be relaxing—of course, it wasn’t! It was much steeper and more winding than I expected, forcing me to brake constantly. At one point, in a moment of distraction (I was probably just exhausted from the sun), I missed a turn and went straight down a slope. I had a split second to react—just enough time to jump off the bike before crashing into a tree. There I was, lying on the ground, my leg smeared with chain grease and my knee scratched from the thorns. The tree stood just a meter away. That was close. I quickly stood up and checked if everything was okay. With a surge of adrenaline, I carefully made my way down the rest of the descent to the hotel. A shower, dinner, and then I collapsed into bed.

Did I boot up OpenBSD? No. Did I think about the hackathon? Also no.

Day 3
#

Komoot - 80.1 km 🏁 👍 910 m 👎 920 m

Day three was set to be a quieter one. I had no plans to ride all the way to Prague today, as the sun was going to be intense again. Instead, I picked a small town between Karlovy Vary (Carlsbad) and Prague as my destination. However, I decided to spend the morning exploring Karlovy Vary a bit more on my bike. It’s a really beautiful place, though quite touristy. The highlight of the day came after just 6–8 kilometers: an incredible view of Karlovy Vary from above. It was absolutely stunning.

Unfortunately, the rest of the ride was far less exciting. The route took me along roads with no cars and through villages that seemed lifeless. Still, I enjoyed a bit of the Czech countryside as I made my way through the quiet. When I finally arrived in Rakovník, I found a nice apartment waiting for me and had plenty of time to relax.

So, I opened my laptop to check out the OpenBSD mailinglists.

Day 4
#

Komoot - 59.1 km 🏁 👍 590 m 👎 690 m

The last few kilometers into Prague—this was the plan, and it turned out to be a very relaxed morning. I aimed to arrive at the hotel around check-in time. The ride itself didn’t have any major highlights, but I started noticing a shift. What had been peaceful, solitary rides through forests in recent days gradually transformed into more populated, industrial areas. The suburbs of Prague became more and more apparent, and before I knew it, I was in the city, even though I was still 20 kilometers from the center. My destination: Hotel William.

I mapped out the route to get a good view of Prague from above. Arriving at Petřín Gardens, I spent some time enjoying the view, taking in the calm before the hackathon began.

At Hotel William, the first person I ran into was Theo. We exchanged greetings, and he showed me the way to the hackroom. I asked him about his bike trip, but unfortunately, he hadn’t been able to make it this time. However, he already had new plans for after the hackathon. Our conversation left me excited for the event. I was able to store my bike in my room and take a short rest before heading to what would become the hottest hackroom in the world.

c2k24 report
#

I usually start a hackathon in /usr/ports and stay there until the very end. This time, out of habit, I began in /usr/ports again—but only to finish up my latest updates to CMake and KDE. These updates had been sitting around for a while, waiting for some testing, and I finally committed them.

Before the hackathon, I had spent some time learning about the Video Acceleration API (VA-API) and had some success getting it to work with my Intel GPU in the ports system.

Even before the hackathon, I was able to play a 4K video using multimedia/mpv without my CPU overheating. These were just fun experiments, but I wanted to make sure everything was working properly.

OpenBSD VA-API support
#

I decided to dedicate this hackathon to working on VA-API. The first thing I needed was a benchmark. Using mpv profiles, I could determine how many FPS were achieved when playing a 4K video with and without VA-API support. A quick glance at the CPU usage was enough to tell whether the video was being handled by the GPU or CPU. If it ran on the CPU, top(1) would quickly show usage soaring above 100%.

[bench-nova]
#audio=no
vo=gpu
untimed=yes
video-sync=display-desync
osd-msg1="FPS: ${estimated-display-fps}"

[bench-va]
#audio=no
vo=gpu
hwdec=vaapi
untimed=yes
video-sync=display-desync
osd-msg1="FPS: ${estimated-display-fps}"

Using mpv --profile=bench-va v.mp4 and mpv --profile=bench-nova v.mp4, I found a reliable test case. I shared my results with @matthieu. Based on his feedback, I spent the rest of the hackathon working on integrating libva into /usr/X11R6 and building the AMD drivers (libgallium_drv_video) with VA-API support.

I dove into Xenocara’s build system and quickly made progress. With support from Alex @jsg, I figured out what was needed in Mesa to build libgallium_drv_video with VA-API support. The key was reading through the Ninja build files and identifying the dependencies for each component — a tedious but necessary task! After about 1–2 days, everything was ready to be shared with the other developers.

The main challenge I faced was that I could build everything but couldn’t test it, as I didn’t have AMD hardware. After 2–3 hours of chat-driven development with @martijn, we finally got the desired output from vainfo:

libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: Mesa Gallium driver 23.3.6 for AMD Radeon RX 7900 XTX (radeonsi, navi31, LLVM 16.0.6, DRM 3.54, 7.5)
vainfo: Supported profile and entrypoints
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointEncSlice
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileAV1Profile0            : VAEntrypointVLD
      VAProfileAV1Profile0            : VAEntrypointEncSlice
      VAProfileNone                   : VAEntrypointVideoPr

With that, I had a finished diff for xenocara and felt really proud. It was my first piece of work that touched all three areas: src, xenocara, and ports.

To test your graphics card and see which encoders/decoders are supported, you need to install sysutils/libva-utils and run vainfo.

VAEntrypointVLD indicates that your card can decode the specified format, while VAEntrypointEncSlice means you can encode in that format. In the example above, H264, HEVC, JPEG, VP9, and AV1 decoding are supported, as well as H264, HEVC, and AV1 encoding. If something goes wrong, you’ll see the following error:

libva info: va_openDriver() returns -1

Currently, multimedia/mpv is the most reliable tool for utilizing VA-API on OpenBSD. Check the log by running mpv --hwdec=auto video_filename and look for hwdec for more details.

Intel
#

The Intel VA-API drivers can be found in graphics/intel-media-driver and graphics/intel-vaapi-driver.

The new media-driver supports the following platforms:

  • BDW (Broadwell)
  • SKL (Skylake)
  • BXTx (BXT: Broxton, APL: Apollo Lake, GLK: Gemini Lake)
  • KBLx (KBL: Kaby Lake, CFL: Coffee Lake, WHL: Whiskey Lake, CML: Comet Lake, AML: Amber Lake)
  • ICL (Ice Lake)
  • JSL (Jasper Lake) / EHL (Elkhart Lake)
  • TGLx (TGL: Tiger Lake, RKL: Rocket Lake, ADL-S/P/N: Alder Lake, RPL-S/P: Raptor Lake)
  • DG1/SG1
  • Alchemist(DG2)/ATSM
  • MTLx (MTL: Meteor Lake, ARL-S/H: Arrow Lake)

the older graphics/intel-media-driver supports only the old GEN Graphics family. For now you have to install your intel driver with pkg_add by hand.

AMD
#

VA-API on Radeon HD 2000 and newer GPUs is supported by our xenocara mesa. In short, there’s nothing you need to do for AMD.

Next #

My work on VA-API was just the starting point, and I hope more and more ports will benefit from it over time. Of course, this won’t happen on its own, and there’s still a lot of work ahead. Since the hackathon, @jsg and @matthieu have contributed many small improvements. GuC/HuC has already been enabled in our i915_driver but ONLY on Adler Lake. Unfortunately, with DG2, there are still memory corruption issues. These have kept @jsg busy for a while, which is why only Alder Lake support has been enabled so far.

“HuC firmware is necessary for AVC/HEVC/VP9/AV1 low power encoding bitrate control, including CBR, VBR, etc. The default kernel configuration didn’t enable HuC loading for TGL/RKL and legacy platforms but enabled it from ADL+ platforms. You could change the HuC setting with “options i915 enable_guc=2” > /etc/modprobe.d/i915.conf under root. For ADL+ platforms, the kernel loads HuC as default if the related” – README.md https://github.com/intel/media-driver

I’m sure we’ll see more and more fantastic developments in the future. But for now, let’s look forward to the upcoming OpenBSD 7.6 release!

With this in mind: Shut up and hack!

Thanks
#

A big thank you goes out to your host, for making this happen, and to our sponsors, the OpenBSD Foundation! Danke Prague!

A special thanks to all who support my work with a small donation on Sponsor my work.