georgebakoulis.dev

The Bottleneck Wasn't the Code

Day two of Pharos and the script is already slow.

The plan was simple: take yesterday's array of objects and hang the html content off each url. A one-function job. Turns out the function wasn't the problem.

Here's what we had going in:

[
  {
    url: 'https://georgebakoulis.dev/blog/coding-books-or-courses',
    lastmod: '2026-03-22T18:02:03+00:00'
  },
  {
    url: 'https://georgebakoulis.dev/blog/journey-into-ambient-music',
    lastmod: '2026-03-22T18:02:03+00:00'
  },
  {
    url: 'https://georgebakoulis.dev/blog/brand-new-2015-macbook-air',
    lastmod: '2026-03-22T18:02:03+00:00'
  },
  // rest of the objects
]

Branch: https://github.com/bak-george/Pharos/pull/1

Too slow for a 3-function codebase

Three functions. My sitemap.xml is tiny. And the script is already dragging.

To make sure I wasn't imagining it, I ran time node src/bench.js and got:

node bench.js 0.22s user 0.05s system 6% cpu 4.390 total

Here's what those numbers mean:

Value Meaning
user CPU time spent running your code
system CPU time spent in the kernel (system calls, I/O)
cpu Percentage of wall-clock time the CPU was actually busy
total Real elapsed time — how long you actually waited

Look at the "cpu" row. 6%. Four seconds of wall-clock time and the CPU was busy for less than a third of a second. So the CPU wasn't the bottleneck — something else was eating the other 4 seconds.

It was waiting for the network.

Next up: why the script is waiting for the network.