Hi there 馃憢

Welcome to my blog

How Long Does a System Call Take?

I鈥檓 learning about CPU virtualization and the Limited Direct Execution model. As part of that, I got some homework1 to measure how long a system call takes. The book suggests: Measuring the cost of a system call is relatively easy. For example, you could repeatedly call a simple system call (e.g., performing a 0-byte read), and time how long it takes; dividing the time by the number of iterations gives you an estimate of the cost of a system call. ...

September 20, 2025 路 2 min

Performance Issues with Large Data in window.history.state

TL;DR: Storing full collection data in window.history.state is expensive (serialization time, retained memory, and browser size limits). Prefer storing cursors/params and keep large data in an in-memory cache keyed by URL; use sessionStorage/IndexedDB if persistence is required. I鈥檝e found an interesting issue with the Shopify Hydrogen component because it saves all nodes on a page in window.history.state as you can see in this line. For the particular website I am working with at the moment, the collection page has quite a bunch of data. When I tested, showing about 100 products on the page meant having ~8MB for the serialized version of the object using JSON.stringify. Deserialized structures also incur engine overhead (object headers, indices). The Pagination component from Shopify that we use does many things, but what I want to emphasize is that it saves the collection data in window.history.state: ...

September 18, 2025 路 4 min

File Descriptors and stdout redirection

I took a few computer science electives during my Mechatronics Engineering major, but unfortunately I didn鈥檛 attend operating system lectures, although I had all the pre-requisites. I鈥檝e decided to study the subject and I鈥檝e found a free book which is quite good. On Chapter 5 about the Process API, there are details about how the Unix Process API works, detailing some system calls. I鈥檝e found the trick for file redirection particularly interesting: ...

September 17, 2025 路 2 min

Resizing FreeBSD QEMU Images: Fixing 'Truncated ELF File' Errors

I鈥檝e been curious about FreeBSD and wanted to try it on QEMU. FreeBSD has instructions for running it. As I鈥檓 using an Apple Silicon machine, I paid attention to the HVF acceleration option. I first logged in via Telnet, but once SSH was set up, I ran it in the background with a small script (./run.sh &): #!/bin/sh qemu-system-aarch64 -m 4096M -cpu host -M virt,accel=hvf \ -bios edk2-aarch64-code.fd -display none \ -drive if=virtio,file=FreeBSD-14.3-RELEASE-arm64-aarch64-ufs.qcow2,id=hd0 \ -device virtio-net,netdev=net0 -netdev user,id=net0,hostfwd=tcp::2222-:22 This worked well, but as I installed more packages I eventually hit a weird error: ...

September 14, 2025 路 3 min

My Bun Migration Story: From CI to Local Development

My Experience with Bun I鈥檝e been using Bun for a while now. The first time I鈥檝e heard about it I thought it was cool that it uses JavaScriptCore instead of V8 and that I could use it as a drop-in replacement for npm install. As a web developer working on Shopify Hydrogen apps, I ended up just staying with the project defaults, which meant npm. Moving CI to Bun However, as we added more steps to our CI, like additional lint rules, I noticed the pipeline slowed down significantly. In particular, I observed that our dependent steps spent substantial time on the installation phase. Due to that, a year or so ago I decided to experiment with Bun on our CI for all our steps, including deployment. ...

September 13, 2025 路 3 min

HTML - Semantic Meaning and the Anchor Element

When I reviewed HTML for my current job, I was concerned about using elements that not only contain style but also meaning, semantics. This is something I saw frequently while studying iOS on my free time and and only later I found out the web also had it, but I never paid attention to it as I was too busy thinking about layout, styles and data. However, using elements with semantics help us convey our intent better and the browser can also help us with common implementations for the element we used. ...

September 16, 2022 路 2 min

Solid Parakeet

I have been working with VueJS for a while, but I also have some ReactJS experience. I was curious to see how the framework and ecosystem advanced in the couple years I hadn鈥檛 touched it so I decided to read some docs. I got excited and also created Anki cards for it to sediment my knowledge, but that鈥檚 a topic for another post (let me know if you are interested in knowing more how I do it). In this post, I intend to show you the main points I learned of each item, mixing it with some thoughts from previous experiences, and what the demo app (Solid Parakeet) does (which is not much really). ...

June 4, 2022 路 5 min

Unit tests with Vapor and Postgres

Introduction Vapor makes it easy to write unit tests for server-side applications. I particularly find it fantastic that tests can run in memory, not even opening a port. Also, the database can be changed quite easily to use in-memory SQLite: app.databases.use(.sqlite(.memory), as: .sqlite) Doing that would allow a unit test to be quite lightweight. However, I had some issues with that approach. This post is about explaining what that issue was and how I ended up changing my unit tests to use PostgreSQL directly. ...

January 29, 2022 路 5 min

Building multi-architecture Docker images: why and how

Docker is quite a famous piece of tech. It solves the problem of making software that runs easily across machines (mostly for Linux servers). I won鈥檛 get into details, but it uses Kernel level functions to isolate containerized programs so that we don鈥檛 need to bother about installing the right dependencies on every machine we want our software to run. Instead, we build a docker image, publish it and whoever has docker in their machine can then run it as well as long as the machine has Docker installed. ...

January 22, 2022 路 8 min

A Shell Configuration

I spend a lot of time on the terminal. I started with vanilla terminals on Ubuntu and macOS. Later I learned about terminals with a few "batteries" included like iTerm2 and HyperJS. I have also used tmux extensively before, but ended up switching a few months later to use window splitting from iTerm2 and also profiles, which can login to a shell session automatically. Well, enough of history. This post will introduce you to a basic shell configuration. Ok, it is not basic. However, for me it is the difference between bearing and loving my terminal setup. Topics I will talk about are the following: ...

April 10, 2020 路 7 min