r/devops • • 9d ago

Discussion Solo dev, 4 self-hosted Windows runners on one laptop, merge trains take ~2 hours. How would you speed this up?

edit / update (nov 18):

got a lot of good advice here so i tried some of it, and a few things didn't go how i expected.

i thought tagging tests by area would be enough to pick what to run, but when i checked it on one change the tags missed 47 of the 91 test files that a list based on what imports what caught, including one that actually mattered. so i dropped the tags for now and i'll try them again after the cleanup. right now it's just the change's own tests while i'm writing, then everything that depends on the changed files when i push, and the full suite still runs before anything lands.

i figured the quick set of tests would take about a minute. turns out it was more like 7 and a half and didn't catch anything extra, so that's gone too.

i also tried skipping the local check before a train, thinking it'd speed things up. it didn't really, 133 min vs the usual 112-141, so i put it back.

and i was off on runner time, it's more like 5-7 hours depending on the train, the last one was about 5.4.

the bigger change is i'm reorganizing the code into clearer layers so a change doesn't touch as many places. i'm doing that before this release now instead of after, so the release will be later than i said. hoping to have it in before it ships if it passes everything, no results yet though. making the timing tests wait for a quiet laptop on their own, a cpu time check on one of them, and maybe trying testmon are all on my list for after that. not changing the timing limits.

questions for people who've done this on a big python desktop app:

  1. how did you split yours into layers so each part only depends on the ones below it, and how many layers or folders ended up being enough?
  2. how do you keep it from tangling back up over time?
  3. i'm thinking layers on the outside with feature folders inside the parts that change most. has anyone done it that way, and did it hold up?

solo dev building a windows desktop app, most of the coding is done by claude code sessions (earlier post about that). the bottleneck now is testing. the sessions spend more time waiting on CI than writing code, so i'm looking for ideas

The setup:

  • the app drives blender, unity 2022.3 and the vrchat sdk, so the real tests need windows
  • 4 self-hosted github actions runners, all on my one laptop (ryzen 9 7945hx 16 cores, rtx 4090 laptop 16gb, 64gb ram, 8tb nvme), one job per runner. the real blender/unity jobs can only use 3 of them, and up to 2 local test runs share the same laptop too
  • self-hosted because github's hosted windows minutes cost double and i'm on a tight budget, so the laptop is the free option
  • changes get batched into merge trains, 1-8 changes each, about 3 on average

What a train looks like:

  • pipeline first: 16 real tool jobs (mostly blender, plus unity and a vrm validator) and fake-tool pytest in 4 shards, about 45-80 min
  • then the full windows UI suite, ~25,600 tests in 3 shards, about 65 min. these run back to back on purpose because the timing tests flake when they share the machine with blender jobs, so that's about an hour of every train just waiting
  • a train takes about 2 hours start to finish (83-145 min over the last 8)
  • 7 of the last 8 landed, 4 clean first try. fix and retest loops took anywhere from 30 min to 2 hours
  • laptop averages 55-60% cpu while all this runs and peaks at 100%, ram peaks around 80%

How much testing:

  • every fix starts with a failing test, a review session checks it, the author runs the affected tests locally, then the train runs everything again in CI plus a local gate
  • so the plain python tests end up running about 3 times. the real blender/unity tests did catch the only real failure in those 8 trains though

What i've tried:

  • dev drive, only ~4% faster on my test so i didn't keep it
  • sharding by recorded test duration, and splitting local runs by run time so they stop timing out
  • allowing one re-run of only the failed jobs for flaky infra stuff
  • tags so only affected tests run, built but not measured yet

Why one train at a time: changes often touch the same files, and the timing tests got flaky when all 4 runners were busy. so i'm not sure more runners even helps or if the real answer is a second machine

What i'm asking:

  1. am i over testing? how do you cut duplicate runs without losing coverage
  2. how do you pick tests by changed area without missing stuff that imports across areas
  3. is there a safe way to run 2 trains when changes overlap files, or is one at a time just right
  4. is a second machine or a cloud windows runner worth it for a ~2 hour cycle, or is there a better service for this
  5. how do you keep timing sensitive tests reliable when CI jobs share one pc
  6. could the plain python and fake-tool tests run on linux, or does that risk missing windows-only bugs

at the current pace my next release is about 3 weeks out and the one after that is a couple months, so anything that shortens the 2 hour loop helps a lot. thanks!

0 Upvotes

34 comments sorted by

5

u/Zotlann 8d ago

Think about what the point of testing frequently is. This is super important if your tests are expensive to run and unreliable.

Does having the agents waiting for a green test pass actually buy them anything? Could you just run them on a schedule, say twice daily and have separate agents identify debug and fix the failures or do they need context from the implementing agent? Is that context better stored somewhere else like a ticketing or feature documentation system so that a new agent can get necessary context to fix the failures without introducing new regression or deviating from the product vision?

1

u/BlackberryOk182 8d ago

fair question. the waiting that actually hurt was each session's own test runs before its change was ready, it'd rerun a big chunk of the suite after every fix. once a change goes into a train the session doesn't sit on it, it moves on to its next thing. so the next change cuts those pre-ready runs down to a ~1 min fast set plus one full run at push

i don't think i can stop waiting on the train though. the fake blender tests missed 3 real bugs lately and only the real blender runs caught them. running it twice a day would also mean way bigger batches, so when something breaks it's harder to tell which change did it. the bigger waste turned out to be the same tests running in a bunch of places, roughly 4 of the ~9 laptop hours in a train by my guess, so the train running right now is skipping the extra local test run that used to go alongside ci

on separate agents, review and train runs are already separate sessions. today a timing test failed just because the laptop was too busy, and 3 different sessions checked it on their own and all agreed the change wasn't the problem. for context, i'm piloting a small file with one row per item so a fresh session can pick up an item without needing the author's chat. haven't gone the ticket system route, felt like it'd mostly duplicate the handoff notes and inboxes

3

u/hashkent DevOps 8d ago

Can you get another windows machine?

0

u/BlackberryOk182 8d ago

not right now, a second windows box is hard to justify cost wise. hosted windows minutes are 2x too, so i only use those for one clean check at release time

for now i'm squeezing the one laptop. timing tests only run after the blender/unity jobs finish, local runs are capped at 2 at low cpu priority, and the affected-tests-only tags are built but not measured yet. still hit a load flake today though, a test with a 1.5 sec limit failed while 2 local runs and 2 ci jobs were sharing the machine, and it wasn't the change being tested

if i do add hardware it'd probably be to run the ui/timing suite on its own box, since that's about an hour of waiting per train. rough guess is that gets a train from ~2 hours to somewhere around 1-1.3. problem is a cheap used box wouldn't keep up with blender/unity, and once i'm spending over $1k i'd rather get something decent. but ram and gpu prices are way inflated right now, so most of that money would just go to overpriced parts

so for now i'm trying to squeeze more out of what i have. if you've got ideas on restructuring how the trains or tests run on one machine so it goes faster and smoother, i'm all ears

1

u/NUTTA_BUSTAH 8d ago edited 8d ago

You are over testing for sure. It is a common trap with agentic workflows. I imagine you can give your agents a goal of deleting 75% of tests while preserving functionality, correctness and user journeys through integration and e2e tests. They will probably meet it after a few hours on that scale (well, more like days since every change seems to take hours instead of seconds or minutes).

Do not test everything all the time for every change. Test the immediately important stuff often, run the bigger suite only before releasing a new version. Aim for the important tests to finish in 1 minute. Trains can implement this idea which I assume you already do from the explanation.

Some apps are just a pain to test and require a lot of time. Chances are you did not design the software and thus you have to over-test by your own / your agents design. Good software is well compartmentalized and cohesive thus fast and easy to test.

You can also attempt self improvement. Set benchmarks the agents must maintain. But be careful you set guard rails so the maintenance is not deleting important stuff just to please a metric.

1

u/BlackberryOk182 8d ago

yeah you're probably right, at least partly. when i dug in, a lot of it was the same tests running over and over in different places, not just too many tests. the train running right now is the first one without the extra local test run beside ci, and next up the session writing a fix runs a ~1 min fast set while it works and the full list only once before it pushes. right now every train still runs the big suite too, so that's worth a look after

i'm holding off on deleting 75% though. the tests that catch the most for me are the tiny ones that run in seconds, so a big cut could take out the useful stuff. there's also a minimum number of tests that have to run, and the agents can't loosen or skip tests, which kind of works as the guard rail you mentioned

fair point on the design too. i've started tagging tests by area so only the affected ones run, and splitting things into cleaner pieces is probably something for the next version, just feels too risky right before this release

1

u/Ok-Form1598 8d ago

for 5 i'd change the timing tests so they stop caring how busy the machine is. a 1.5 sec wall clock limit on a box that's also running blender mostly measures blender. if what the test really guards is "this didn't get accidentally slow", assert on process cpu time, or count the work (calls, redraws, file reads) instead. then the ui suite doesn't need the laptop to itself, and that hour of back to back waiting can overlap with the blender jobs. keep a few true wall clock checks for the hosted windows run at release.

1

u/BlackberryOk182 8d ago

good idea, and i looked into it. turns out the ui suite already leaves the timing tests out, those run on their own once the laptop is quiet. the reason the suite still waits on blender is a rule i made after one flaky run, and it really only needs to apply to the timing tests, so i'm going to narrow it to just those. i'm not expecting a huge speedup though, because the last train was about 7 hours of runner time, so with 4 runners it can't finish much under 2 hours even packed perfectly

you're right that load is the problem with them though. none of the ~9 timing failures lately were real bugs. about half my 36 timing tests are just checking how fast something calculates or that it doesn't wait around, and those could get a cpu time or work count check. the rest check stuff like the app staying responsive or blender actually closing when it's killed, and a frozen or hung process barely uses any cpu, so those need real seconds. if i do it i'd add the cpu check next to the old one instead of swapping it. thinking about trying it on one test first to see if the numbers hold steady

and i'd rather keep the real-seconds checks local, since hosted windows minutes cost double

1

u/meowrawr 8d ago

There is a whole science/art to setting up efficient build chains.

For our CI/CD, we don’t build everything and instead determine what actually needs to be built and which tests belong to affected code changes. Although we have a more typical microservice architecture, in theory it’s the same approach as your own software should have a variety of libraries/modules/packages.

1

u/BlackberryOk182 8d ago

yeah you're right, and honestly that's where i fell short. i already tag tests by which part of the app they cover, but when i actually checked, about 45% of the internal imports cross areas. the app grew fast and the pieces got tangled, so picking tests by area alone could miss stuff. for now i'm going to include anything that imports the changed area too, and log that next to the full list on the next trial to see if anything gets missed

the real fix is splitting it up properly so areas only depend on each other one way. that's planned for the next version. there's 107 train branches already merged into the current release so it's a lot of code to untangle, my rough guess is 3 to 6 weeks, maybe less if a script does most of the file moves. after that each update should only need to test the areas it touches. do you know a faster way to do a split like that?

1

u/smell-that-code DevOps 6d ago

In my case, with more and more microservices added to my project, the CI pipeline runs were starting to take a long time and I had to purchase some more build agents. But I started to split up the testing steps out of the build steps, and moved the testing step to AFTER the DEV deploy and gated it. I did this because in most cases I already run the tests locally anyway before I push the updates, and this way it is eating up less CPU and time for the pipeline runs. Also I set up a separate fast local build machine that performs only the CI testing steps.

1

u/BlackberryOk182 3d ago

that's kind of where i ended up too. the split i mentioned actually landed a lot faster than i thought, i figured 3 to 6 weeks but the script did most of the file moves and it was in within a couple days. still cleaning up after it, but the big part is done. i also dropped github actions completely, everything runs locally now. there's no dev deploy for me since it's a desktop app, so the full check runs before anything lands instead. no separate build machine either, it's all one laptop, so the tests share it with blender and unity. what i'm trying next is only running the full check on the final version instead of every time something changes, and running more tests at once since there seems to be a lot of idle cpu. did the separate machine make a big difference for you or was splitting the steps the bigger win?

1

u/smell-that-code DevOps 3d ago

The separate machine was useful because it is run from my own hardware, which is more performant than the small Linux Azure Devops agents. In the beginning those were fine, but since I am now letting Claude write almost all of my code (Sonnet on high effort), it has been creating so many unit tests that the testing step was starting to take up most of the CI time. Some of my apis now have 5000 tests, which I thought was insane. But the sheer number of tests was causing those linux agents to almost run out of memory and to become very slow (like 12 minutes to run the tests of 1 api).

1

u/1saltypistachio 8d ago

Testing comes in tiers. Small changes needs to test only what you touched, larger changes needs to test what you touched and what touches that and majour changes tests more. If you are doing things in a rolling release way, then do a full regression every N number of new code you added. If it's a minor release, run the entire test suit. If it's a major release, run full suite plus non functional tests.

1

u/BlackberryOk182 8d ago

pretty much what i'm moving toward. right now the full suite runs on every batch before it lands, so the every-N part is basically N=1. i'm trying the smaller tiers now though, while writing a change only a quick set plus that change's own tests run, then the full list once before push. on the trial i'm logging touched-only, touched plus whatever depends on it, and the full list side by side to see if the smaller picks ever miss something

the depends-on part isn't very precise yet because about 45% of my imports cross areas, which is why i'm splitting things into clean areas for the next version. after that a proper tier setup per release makes a lot of sense, especially adding perf and install tests for bigger releases

1

u/iGamingTools 8d ago

on moving the plain python tests to linux, what bites is mostly filesystem stuff. windows won't let you delete or rename a file another process has open, paths are case-insensitive, and long paths can still hit MAX_PATH. if the fake-tool tests touch files a lot, i'd keep one windows shard of them in the train

1

u/BlackberryOk182 8d ago

good to know, and that's a big part of why everything stays on windows for now. the app drives blender and unity on windows, and all the tests run on the same windows runners, so there's no linux leg to keep a shard of yet

1

u/Kookoombar 8d ago

I'd move the plain python and fake-tool pytest to a linux runner (WSL or a cheap linux box). Only the windows-only stuff really needs the real machine, and that takes a chunk of load off the laptop. For picking tests by changed area, coverage-based selection like pytest-testmon handles cross-module imports better than hand tags since it tracks what each test actually touches. I'd keep a full run nightly to catch whatever it misses. For the timing flakes, I'd either widen those hard 1.5s limits a lot or put them in their own job that runs alone.

1

u/BlackberryOk182 8d ago

the linux idea makes sense in general, but the app drives blender, unity and the vrchat sdk on windows, so the tests that use the real tools have to run there anyway. wsl would also run on the same laptop, so it adds load instead of taking it off. every train already runs the full suite before it lands, so a nightly run wouldn't add much. i'm also restructuring the code right now so changes touch fewer places, and i'll look at smarter test picking like testmon after that. i'd rather not widen the timing limits, the timing tests are already their own job that runs after the rest finish

1

u/Hostman_com 8d ago

If those two hours are mostly full-suite reruns after small edits, run a quick Windows smoke test on each push and keep the full suite as a required check before merging.

Before adding runners, time the same job with one runner active and then with all four busy. If the job itself slows down, check CPU, memory and disk activity on the host.

1

u/BlackberryOk182 8d ago

that's pretty much where i landed. while writing it's just the change's own tests, at push it's everything that depends on the changed files, and the full suite runs before anything lands. timing one runner against all four busy is a good idea, i haven't timed that directly yet. trains take about 5-7 hours of runner time depending on the train, the last one about 5.4, and the laptop hits 100% at peaks, so the host is probably part of it

1

u/MongooseWonderful198 7d ago

For keeping it from tangling again, Import Linter’s layers contract checks the dependency direction, including indirect imports. It can also forbid imports between sibling feature modules in the same layer. I’d add the check to CI around one boundary you’ve cleaned up, then expand it; moving files into new folders alone won’t stop the next change adding the old dependency back.

1

u/BlackberryOk182 7d ago

that's pretty much what i ended up doing, just homemade. there's a small check in my local test gate that counts imports going the wrong way or sideways between sections and fails if that number goes up, so it can only go down from here. still a good chunk left to clean up. i'll look at import linter once that's done, might be easier than keeping my own.

1

u/addy3006 7d ago

do you know which module pulls in the most tests transitively? if the Blender/Unity adapters sit near the bottom of the graph, splitting them out might be a cheap first boundary. you could compare affected-test count and runner time before and after that one move, before committing to the full layering.

1

u/BlackberryOk182 7d ago

good question. i haven't measured that per module yet, right now my affected test list just matches by name. i did check the shared test helpers and none of them pull in most of the app, the widest one reaches about 115 of the 1145 files. the blender and unity code actually sits more in the middle and top than at the bottom, so it might not be the cheap first split. getting a real number for which module pulls in the most tests and doing a before and after on one move is a good idea though.

1

u/deployfan64 7d ago

7 hours of runner time on a laptop that only hits 60% cpu means yyour shards are sitting idle waiting on each other somewhere

1

u/BlackberryOk182 6d ago

that was the old setup, i've since moved everything off github actions and run the tests locally now. each part of the app gets worked on separately and only tests what its change touches, and the full check before anything lands is split into about 12 chunks balanced by how long each test file takes, around 15 min each. the cpu sits around 12-20% because it's only 1 or 2 test runs at once at low priority on a 32 thread chip. i capped it like that on purpose so the laptop stays usable and nothing clashes with blender and unity. you're right that there's room left over though, i'm just not using it yet. if you've dealt with something like this, how would you use more of the cpu without the blender and unity tests stepping on each other?

1

u/Low-Opening25 8d ago

Windows? That’s your problem

1

u/BlackberryOk182 8d ago

yeah, can't really avoid it, the app drives blender, unity and the vrchat sdk on windows so the real tests have to run there

1

u/Low-Opening25 7d ago

fair enough, but vms exist

1

u/AstraeusGB SysOps/SRE/DevOps/DBA/SOS 8d ago

This is a windows app, so not really much they can do to get around that part.

I know, we could say just don't make a Windows app, but alas that's still where the money is

1

u/argo_devbuild 1d ago

the biggest win is prob getting the UI suite off the laptop, since an hour of every train is it waiting for the blender jobs to finish. options are a second windows box as another self-hosted runner, github's larger windows runners, or a per-minute windows runner service like warpbuild for the UI shards, with blender/unity staying on the laptop where the gpu is.

Once the UI tests run on their own machines they can run alongside the tool jobs instead of after them, and the timing flakes from sharing a cpu should go away too. worth checking first that the UI suite runs fine without the gpu and without an interactive desktop session.