/////////////////
//
kmatter.net
//
/////////////////

TVN: The Strong Stuff

/ tags: open_fortress tvn

If you didn’t know already, I’m one of the lead developers for the launcher of Open Fortress, a free mod for TF2.

Now the history of the launchers is a story for another time as it’s somewhat confusing and predates my involvement, but I joined at the beginning of 2021 roughly, and the subject of this post, TVN, was implemented by welt at the beginning of 2022.

Now the first question that a few people may have is “What even is TVN?”

Well TVN is the protocol/schema used by Toast, the system currently implemented for the Open Fortress launcher(s). It specifies how to download from the servers, how to update revisions, and how the files should be formatted on the server. The designer of this schema, welt, states that “it’s a very strong abstraction over a filesystem, as it can be applied to any filesystem.”

This is correct, however it’s also where it slips in real world efficacy. This is due to one simple observation from our own servers:

Downloading one big file is substantially quicker than lots of small files.

How a Toast client (in this case, murse updates to the latest revision can be described as such:

  1. The latest revision is fetched.

  2. The client requests all the revisions from the current one it’s on to the latest.

  3. It then ‘replays’ the revision, gathering a list of ‘changes’.

  4. It then firstly executes all changes that aren’t downloading things (i.e deleting/making directories), then downloads all files to the correct locations.

Now the issue is with step 4, there’s one download per file which from a fresh install can be thousands of files - HTTP/2 overhead kills performance.

Here’s some testing I did, from a fresh install (versus replacing the logic to simply download and extract a zip, which is zip-for-latest):

murse latest, toast3, zip-for-latest: ~2:31
murse latest, toast3, default threads: ~5:10
murse latest, toast3, 256 threads: ~2:23

…Ouch. Now TVN is incredibly useful due to it being such a strong abstraction, you can apply it over the net, over something like 9P, you could probably apply it in person (though human JSON parsing isn’t the most efficient.) However it’s so strong it’s hard to get anything done efficiently if you merely apply it naively like this. Much like Marmite then.

There’s many solutions to this issue, most involving perverting the clean schema with something like the asforementioned zip approach. This simply checks if you’re doing a fresh install, downloads a zip called latest.zip from the server, and extracts it into that folder. Any subsequent update after the initial download is somewhat expected to be smaller, so this should drastically reduce impact on the servers, and decrease download time.

This, in theory, is similar to what linux distros do- provide an iso which users update once running, as opposed to just downloading everything from the server (though they probably do this for different reasons).

Another few approaches were considered, such as Metalinks and just using FTP/HTTP1 possibly, but the first has some major security issues to the point where curl removed it, and the second is pointlessly slow.

Overall, it’s clear to see that something needs to be done, hopefully the zip method or something else equally efficient will be put into the next version of TVN.

-kmt