90: Chapter 90 Let the program find the program
The next day, he ran a full suite of tests.
He compared dozens of gigabytes of results spit out by the old and new workflows.
The results were completely identical.
Then he looked at the final performance metrics.
The old workflow took over five hours to run.
After swapping in his little gadget specifically designed to sort five numbers, it saved twenty-one minutes.
Twenty-one minutes.
Placed into a massive five-to-six-hour task, this number was pitifully small, like scooping a single spoonful out of a barrel of water.
To an outsider, it would seem like he stayed up all night just for this tiny bit of improvement, which was simply picking up sesame seeds while losing the watermelon.
But Jiang Lin did not think so.
Because this tool wouldn't just be run once.
There were dozens of groups in this project that needed to be re-run later, and this tool would take on other jobs in the future.
Saving twenty-one minutes today and twenty-one minutes tomorrow, running it a hundred times would save over thirty hours of high-intensity computing power.
This meant he could use fewer machines to achieve faster iteration speeds.
Furthermore, this was just the first small stone he had plucked out.
In an old, disrepair-stricken system piled high with laziness and redundancy, there were bound to be hundreds or thousands of such small stones.
He summarized it at the end of his notes like this:
"When a task is repeated enough times, the tiniest difference in efficiency will tear open into a chasm of life and death."
In this city, if the code was written wrong, at worst it would cost a few extra bucks in server fees, at worst he'd have to crawl out of bed in the middle of the night to reboot, or at worst roll back and start over.
There was customer support, peers, and countless redundancies to squander.
But in that Wasteland World he would sooner or later return to, there were no cloud servers, no customer support, and no second engineer to clean up his mess.
Over there, if a machine was slow, you couldn't just ask for resources first; you had to ask first:
Why was it slow?
Being slightly faster and more efficient at the bottom layer was never a performance metric written into a resume.
It was the margin for survival.
Writing down these words, Jiang Lin categorized this little gadget that sorted five numbers into a newly created folder.
Then, a new thought floated up.
For five numbers, he could figure it out in one night relying on pen, paper, and experience.
But what about six numbers, seven numbers, or eight numbers?
For every additional number that needed to be sorted, the possible arrangements would multiply over and over, quickly growing to the point where a single sheet of paper couldn't possibly fit them all.
Moreover, the minimum number of comparisons did not equal the fastest actual running time.
You also had to see whether the machine liked this order and where those branching paths were hidden.
By that time, stubbornly relying on a single person's brain to figure out which set of movements was best would become increasingly unreliable.
It wasn't that it couldn't be written.
It was just that humans would become the slowest bottleneck.
Jiang Lin suddenly thought of something.
If the perfect set of movements for sorting five numbers could be found by a machine trying out every possible arrangement one by one on its own...
What about other small actions?
What about those small actions that were similarly repeated tens of millions of times and likewise choked the entire system?
Humans would set the rules, defining what counted as right, what counted as wrong, and what the red lines were that absolutely could not be crossed.
Then, they would let the program test things out on its own, trial-and-error its way through that terrifyingly vast sea of possibilities, and fish out a piece of code that was smaller, faster, and more stable for itself.
No longer would humans bury their heads in writing it line by line.
Instead, it meant writing a program that would let this program seek out other programs.
Alright, letting programs find programs sounded pretty mystical, but what was the actual use of it?
To use the simplest analogy:
You had a Swiss Army knife at home, with scissors, a bottle opener, a screwdriver, a saw, having everything. Carrying one when going out could handle pretty much anything.
But if you ran a factory where the assembly line only did one thing every day—
tightening the exact same type of screw, millions of times a day—would you still use that little screwdriver on the Swiss Army knife to tighten them?
Of course not.
You would custom-make an electric screw gun tailored specifically for this single type of screw, making it fast and steady.
Computers were the same way.
The ready-made functions they usually used were all Swiss Army knives.
Made to be universal and reliable to cope with all situations under the sun, yet every time they were used, the entire complex setup had to be set in motion.
But many tasks in reality were actually just assembly lines tightening millions of identical screws every day.
The actions were simple and the rules fixed, except that the frequency was terrifyingly high.
What Jiang Lin did the night before was, in essence, personally custom-making a dedicated screw gun for such an assembly line.
And letting programs find programs took this matter one step further.
Custom-making a screw gun itself was also tiring work; one had to understand materials and force, and test it repeatedly.
He didn't want to stay up all night personally forging a new gun every time he encountered a new kind of screw.
What he wanted was a machine that could build screw guns on its own.
You just had to tell it, "I want to tighten this kind of screw, it must be tightened securely, and it cannot strip," and for the rest, it would test a thousand kinds of gun heads on its own, measure which one was the fastest and stablest, and finally hand the best one over to you.
Humans were only responsible for making it clear what they wanted and what absolutely could not go wrong.
The work of building the gun was left to the machine.
Then what could this thing do in daily life?
The answer was that almost everywhere an action wasn't difficult but had to be repeated hundreds of millions of times, there was hidden behind it such an assembly line that could be modified.
When you swiped through your phone's photo album and thousands of photos snapped into chronological order instantly, that was sorting.
When you shopped online and commodities were listed from lowest to highest price, that was sorting.
When maps calculated the nearest route for you, when food delivery apps assigned the closest rider to you, or when hundreds or thousands of objects were re-ordered frame by frame in a game...
In these moments that you used every day yet never paid attention to, the underlying foundation was entirely made up of small actions repeated tens of millions or hundreds of millions of times.
Normally, nobody cared whether they were a bit faster or slower, because looking at a single instance, it was all over in the blink of an eye.
But once scaled up to hundreds of millions of repetitions, this blink-of-an-eye difference would turn into concrete electricity bills, server costs, and waiting time.
The machine Jiang Lin wanted to build was meant to burrow into these unnoticed corners, pluck out those small actions that could be even faster one by one, custom-make them, replace them, and speed them up.
Furthermore, it wasn't picky about jobs.
Today it could sort five numbers, and tomorrow it could optimize other small actions.
It could be used on this project, and it could be used just as well on the next project.
At this thought, Jiang Lin became more and more excited.
Because sorting was merely a stepping stone.
What truly made his scalp tingle was the even bigger thing behind this crack in the door.
What if even the task of finding the optimal program itself could be handed over to machines to do?
Then in the Wasteland World, he wouldn't have to personally write the best plans for every single device, every control sequence, and every observation workflow with his own hands.
As a single person, his energy was limited.
But if one day, a machine could search out a portion of small programs, small workflows, and small actions on his behalf—
Then it would no longer be just a sorting tool, but an amplifier for a single-person scientific research system.
In the past, when humans wrote programs, they provided every step with their own hands.
Step one: compare these two numbers; step two: compare those two; step three: swap...
Paving out the answer step by step.
This required the person writing it to have the answer in their head first, and then translate that answer into code.
What Jiang Lin wanted to do now was the reverse.
He would no longer hand over the answer himself, but only tell the machine three things:
What the starting point was—a pile of disordered numbers.
What actions were permitted—pick two positions, compare them, and swap if they were wrong.
What counted as winning—all possible out-of-order sequences eventually getting straightened out.
Then, let the machine test it out itself.
To put it bluntly, it turned the matter of sorting into a game.
The disordered numbers were the chessboard.
Every time a comparison was made and a swap executed when appropriate, that was making a move.
Straightening out all the disordered sequences was clearing the game.
What the machine had to do was play this game by itself, testing it step by step until it found a set of moves that could clear the game.
There was something scalp-tinglingly terrifying about this idea.
Humans no longer needed to know the answer from then on.
Humans were only responsible for defining the game.
Drawing the chessboard well, setting the rules, and marking what victory looked like.
As for how to walk specifically and which path was the fastest, that was left to the machine to brute-force and trial-and-error.
Jiang Lin created a new file and typed out three lines of comments as the entire set of rules for this game.
There is a pile of disordered numbers.
At every step, pick two positions to compare, and swap if they are wrong.
Until all numbers are straightened out.
It was very short.
So short that it didn't look like the beginning of a program at all.
But he stared at those three lines for nearly a minute.
Because the meaning of those three lines was no longer handwritten sorting, but letting the machine search for the sorting program itself.
The first problem to solve was, how would the machine know it had tried and gotten it right?
This was precisely the cleanest part of this path.
Five numbers, all possible out-of-order sequences, totaled only one hundred and twenty.
One hundred and twenty types, small enough to be listed completely without missing a single one.
Therefore, the machine didn't need to guess at all whether a certain set of steps was right or wrong.
It could throw all one hundred and twenty out-of-order sequences in, let that set of steps run through them one by one, and as long as even one sequence wasn't straightened out, that set of steps would be sentenced to death on the spot and discarded.
This was cleanliness in a mathematical sense.
It wasn't that I felt it should be right, but rather that I had tried every possibility, so it was simply right.
Humans rely on intuition; they will miss things and make mistakes.
Machines rely on exhaustive enumeration; not a single one will be let go.
In the early hours of the morning, the first version of the program-finding program started running.
It was very clumsy and hardly ever cut corners, simply trying out choices layer by layer from all the options of which two to compare.
Every time it took a step, it would look back to see how many of the one hundred and twenty out-of-order sequences still remained unstraightened.
Whichever path reduced the chaos the most, it would follow that path downward.
Jiang Lin established a simple evaluation standard for it.
How many were left incorrectly sorted, how many comparisons were used, whether branch roads were introduced, whether the rule of maintaining the original order when two numbers were equal was violated, and whether missing data was isolated in advance.
There was no mystical intelligent model.
There were only three most primitive things: try them one by one, promptly cut off dead ends, and verify all possibilities.
This was all his machine could run right now.
When the first round of results came out, a string of steps was printed on the screen.
Jiang Lin verified it first.
One hundred and twenty out-of-order sequences, all passed.
The case where two numbers are equal, passed.
Isolation of missing data, passed.
Only then did he look at the speed.
It wasn't much faster than what he had handwritten himself, and under certain settings, it was even slower.
Instead, he let out a long sigh of relief.
This was normal.
How could the first version of a program-finding program crush a person's experience gained through staying up all night right out of the gate?
But it had already proven the most important thing.
Machines can find the correct program on their own.
Whether it is fast or not is a question for the next layer.
Whether it can be found is what determines whether this door is open or not.
In the following time, Jiang Lin bit by bit fed this still-clumsy thing.
The first step was to make it distinguish between right and wrong.
This was the simplest; exhaustive enumeration would do.
One hundred and twenty types for five numbers, tens of thousands for eight numbers, the machine could finish verifying them all without missing a single one.
The second step was to make it distinguish whether it was worth it.
Being able to sort numbers correctly as well, there might be a dozen different sets of steps, and they were not equally good.
Some had more comparisons, some had more branch roads, and some required taking up more temporary space.
Jiang Lin had to write these costs item by item into the machine's evaluation criteria, letting it pick out the most cost-effective one among a bunch of correct sets of steps.
The third step was the most troublesome.
Making it understand whether the machine would recognize it.
The exact same set of steps looked similar when written on paper, but once it actually ran, changing computers or changing the translation method would surprisingly result in different speeds.
Because what was ultimately executed was not those few lines of words on paper, but a long string of lower-level instructions translated by the machine.
A set of steps that looked to have the fewest comparisons might not necessarily be the one that ran the fastest when translated into the machine.
At this layer, paper, pen, and intuition completely failed.
Humans simply couldn't calculate which set of steps would be faster in a real machine.
And this was precisely the greatest value of letting a program find programs.
Things humans couldn't calculate, machines could run for real, set by set, and measure with a stopwatch.
It didn't need to understand why it was fast; it only needed to run tens of thousands of candidate sets of steps one by one and then tell you.
This set is the fastest.
But Jiang Lin quickly collided with the natural enemy of this path.
Explosion.
With just slightly more numbers, the possible sets of steps would multiply over and over again.
Five numbers could still be fully tried, but at a larger scale, even if the machine tried without stopping until the end of the universe, it couldn't finish trying all the paths.
At this time, cutting was more important than trying.
Jiang Lin thought of a competition problem he had solved previously.
The key to that problem was not calculating all possible answers, but first proving which answers could not possibly be the best, then crossing them off in batches, and searching only within the remaining small scope.
Searching was the same.
The machine couldn't walk all the paths, but it could first prove that a large batch of paths were destined not to be better starting from a certain step.
Therefore, these paths didn't even need to be tried; they were discarded in batches.
Doing this well didn't require a faster machine, but a smarter abandonment.
At every intersection, calculating in advance that walking this way could at best only reach a certain extent, and once finding that this upper limit was not even as good as the answer already in hand, turning back immediately.
What was saved was astronomical amounts of useless work.
Late one night, the first truly heavyweight result appeared.
Sorting five numbers with dirty data rules.
Allowing equal numbers, allowing missing gaps, and ensuring that after sorting, equal numbers maintained their original sequence.
The set of steps found by the machine was not completely identical to the one Jiang Lin wrote by hand.
The number of comparisons was the same.
But there were fewer branch roads and the structure was more regular.
He fed all the dirty situations in one by one to verify them.
All passed.
Then came the stopwatch.
It was two point something percent faster than the handwritten version.
Changing machines and changing translation methods, the lead margin became smaller, but it didn't disappear.
Two point something percent.
It even sounded a bit pitiful; no one would applaud for this number.
In fact, what was finally left on the hard drive was just an inconspicuous small file, accompanied by an automatically generated verification report.
All out-of-order sequences passed, equal values passed, missing values passed, zero difference from standard practice, median speed two point seven percent faster.
That was all there was to it.
But Jiang Lin knew clearly in his heart the essential difference between it and yesterday's handwritten version.
This time, that beautiful set of steps was not written by a human.
It was fished out by the machine itself from the vast sea of possibilities.
The general workflow in the standard library had been polished by countless engineers for many years.
And now, in a specific scenario, it had been beaten.
Even if it was just a little bit, even if no one applauded.
The one doing the work was no longer some genius's brain, but a machine willing to try every possibility.
He didn't rejoice over this two point something percent for long before quickly frowning.
It was too small.
It wasn't that he looked down on the result, but rather that this result was telling him something.
The direction was correct, but the method was still crude. The game rules he set for the machine were too simple, its ability to make it give up was too weak, and the board it was allowed to play on was too small.
The machine was currently like a novice who had just learned the rules and only knew how to bury its head and stubbornly try.
It could win, but it won clumsily.
And Jiang Lin had already seen where the true end of this path was.
The current machine tried things according to rigid rules.
But if one day, it could look back and learn from the tens of thousands of sets of steps it had tried in the past—
which type of structure tended to be fast, which type the machine particularly liked, and which type looked like it had fewer comparisons but ran slowly—then it would no longer be a novice that just stubbornly tried things head-on.
It would begin to have intuition.
Humans define the game, machines play it, and then from every game played, they develop their own preferences.
By that time, the matter of letting a program find programs would truly have grown teeth.
But Jiang Lin didn't touch that step immediately.
It was still too early.
In his hands, he only had a clumsy program-finding program, a small file that was two percent faster, and a few test reports.
This wasn't an achievement; it was just a crack in the door.
Yet many things that would ultimately change everything were ridiculously weak at the start.
🔊 Text To Speech
Listen while reading