Reading Settings
Font Size
16px
Line Spacing
1.6
Reading Width
900px
Font Share
Theme
Text To Speech

107: Chapter 107 Dimensional Reduction and Deconstruction

School of Computer Science.

Chen Qiming's office was on the fourth floor, and the door was ajar.

When Jiang Lin knocked and entered, this receding hairline systems engineer was staring at two screens.

Besides him, two students were sitting in the room.

The one by the window was in his early twenties, with a somewhat student-like round face, and had been idly spinning a carbon pen in his hand.

Hearing the push of the door, he instinctively turned his head.

The moment he saw Jiang Lin clearly, the pen in his hand dropped onto the desk with a snap, and his entire body bounced up from the chair with a start.

Because he rose too violently, the swivel chair slid back half a meter and heavily bumped against the iron filing cabinet behind it, producing a dull thud.

The round-faced boy opened his mouth wide, his Adam's apple rolled violently, and he forcefully swallowed back a curse that was about to slip out.

This face, over the past half month, had almost swept across the academic sections of major forums across the entire internet, and even crossed boundaries to spark widespread social attention.

In the corner of the office, the other student appeared much calmer.

Around twenty-six or twenty-seven, tall and thin, he was leaning against the server rack with his arms crossed. Seeing Jiang Lin enter, he gave a faint nod as a greeting.

As for Chen Qiming, his reaction was extremely swift and very enthusiastic.

"You're here, you're here, sit down quickly!"

As he spoke, he moved a stack of printer paper from his chair to the floor and pointed at the two young men in the room.

"These are two students I mentor, Qiao Yue, a first-year graduate student who just joined the group and is doing program synthesis with me. That one is Pei Li, a veteran Ph.D. student who is tackling superoptimization on his own."

The moment the words "veteran Ph.D. student" were uttered, Jiang Lin understood crystal clear in his heart where the understated, scrutinizing gaze from the corner was coming from.

In the trade of computer systems engineering, a veteran Ph.D. student usually meant countless all-nighters spent troubleshooting memory leaks, meaning crawling out with thick calluses from the ocean of assembly instructions and the labyrinth of microarchitectural features.

For someone who does close-packing and pure mathematics to cross boundaries and run into the systems group to discuss low-level performance optimization work—to any pragmatic engineer, this reeked of absurdity.

Therefore, Pei Li maintained the rigor and vigilance of a senior systems engineer.

And his posture had already clearly expressed his subtext.

The mathematical construction of the Jiangs Brick was indeed incomparably magnificent, but that was fundamentally a completely different matter from underlying hardware optimization.

No matter how sharp the blade of theory was, it might not necessarily cut through the intertwined mess of engineering.

"Did you take a look at rank5 and sort5 during this trip over?"

Chen Qiming rubbed his hands together, asking with a face full of anticipation while also somewhat worried that Jiang Lin would directly throw out a sentence like "That is a meaningless layman's question" to end the possibility of this cross-disciplinary cooperation.

"I've looked."

Jiang Lin skipped any superfluous pleasantries and asked Chen Qiming for the machine specifically used for offline testing.

"Teacher Chen, let's state the conclusion first. This path is viable both theoretically and engineering-wise. But the specific way of walking it might be a bit different from what you initially envisioned."

He gripped the mouse, clicked open the root directory of the USB flash drive, and double-clicked to open the first folder among a neat row of directory trees.

verify_sort5_zero_one.

Jiang Lin turned around, met Chen Qiming's gaze, and asked, "Teacher Chen, I''d like to confirm a basic question first. How is the correctness of this version of the sort5 code your team is currently running confirmed? How do you ensure it won't make mistakes under any extreme circumstances?"

Chen Qiming was slightly taken aback, seemingly not expecting Jiang Lin's angle of cutting into the problem to be so basic.

Pushing the glasses on the bridge of his nose, he answered truthfully, "It mainly relies on high-intensity stress testing. It's not simply testing five distinct integer permutations, but pouring in all the 5-tuple forms extracted from the real pipeline. Duplicate values, missing sentinels, abnormal re-weighting scales, zero-transaction windows of low-liquidity targets, extreme fluctuation boundaries, and integer values near overflow. The pipeline has run tens of billions of sets, and no errors have been caught."

Jiang Lin nodded: "These stress tests can cover a large amount of engineering dirty samples, but it is still sampling. It can prove that these tens of billions of times were correct, but it cannot prove that the sorting network topology itself is without error."

The smile on Chen Qiming's face slightly stagnated.

As an architect who wandered deep in the system for years, a rigorous scholar who would never dare to merge code with even a one-in-ten-thousand hidden danger into the main framework, Jiang Lin's words struck the most sensitive and helpless nerve deep within his heart.

Exhaustion in engineering was often impossible; they could only rely on massive probabilities to comfort themselves.

"I'll change the verification approach."

Jiang Lin cast his gaze back toward the screen, his fingertips tapping the Enter key on the keyboard.

The black terminal window popped up, and a short script program started running amidst the blinking of the cursor.

"In sorting network theory, there is a conclusion that is not new, but is rarely truly used by systems engineers as an engineering gatekeeper—the Zero-One Principle."

"What we are currently facing is a sorting problem of five positions. According to the Zero-One Principle, each position has only two possibilities: either 0 or 1."

"2 to the 5th power, at most, is just thirty-two states in total."

On the terminal screen, the progress bar filled up almost the exact moment Jiang Lin's voice fell.

A vibrant green prompt leaped onto the screen.

PROVED.

"Teacher Chen, as long as these thirty-two edge states all pass the test, the correctness of this sort5 of yours will no longer be the probabilistic confidence established by testing billions of times without overturning."

Jiang Lin pointed at the green characters on the screen and said.

"Instead, it is stamped and certified by rigorous mathematical theorems; not only was it not wrong in the past, but it has been proven that it will never overturn."

"Because the resource consumption and long wait of tens of billions of times have been dimensionally reduced and compressed into a mere thirty-two times. Moreover, these thirty-two times provide a proof that leaves no blind spots."

The air in the office seemed to freeze at this instant.

"That's just thirty-two sets?" Qiao Yue leaned closer to the screen from the side, his voice somewhat warped out of disbelief, "Compressing the test scale of tens of billions of sets directly into thirty-two sets, and it can actually be upgraded to a proof logically?"

"This is a guarantee bestowed by underlying theorems. At the layer of the abstract sorting network, not only was it not wrong in the past, but it can be proven that it won't overturn due to input combinations. Of course, the premise is that the comparator semantics are not deformed, the input domain satisfies total order, and the subsequent source code, compiler, and machine code levels must be verified separately," Jiang Lin explained.

"As long as the input sequence of 0 and 1 is completely sorted correctly, then for any input satisfying the total order relationship, this sorting network topology is bound to sort correctly. However, NaN, signed zero in floating points, or the comparator itself carrying side effects are not within the scope directly protected by this theorem."

Chen Qiming gazed at the green PROVED on the screen, his Adam's apple rolling involuntarily.

He had spent his whole life doing underlying systems, struggling through the quagmire of registers and instruction sets for countless days and nights. He knew better than anyone else how deep a chasm truly lay between high-confidence testing and mathematical correctness proven.

What random testing endowed engineers with was the confidence to push code into the production environment.

What this seemingly understated thing before his eyes endowed was an irrefutable verdict.

Pei Li in the corner, whose arms had been crossed all along, slowly lowered them at some unknown point.

Jiang Lin's words that sampling was not proof did not just sting Chen Qiming.

Over these past three years, Pei Li had been day-in and day-out constructing his own superoptimizer.

He tried to use algorithms to find the optimal solution among massive instruction combinations.

But as for those machine codes with outstanding performance searched out by algorithms, nine times out of ten he dared not deploy them online directly.

For no other reason.

He could not mathematically prove that those bizarre instruction combinations were logically absolutely equivalent and correct.

That it could be used was run out by machines day and night running tests.

Whether it was correct or not, a sharp thorn always hung in his heart, constantly worrying that under some rare microarchitectural state, the program would crash entirely.

And at this moment, the green PROVED quietly glowing on the screen before him happened to be the only antidote to pull out that thorn in his heart.

The office fell into a silence lasting over a dozen seconds.

"Can this verification fixture of yours make such a definitive judgment for any piece of sort5 code with different structures?"

When Chen Qiming spoke again, his voice became somewhat tight.

"Any sort5 sorting network expressed by compare-exchange primitives can." Jiang Lin's reply did not have the slightest hesitation.

"But what it proves is the correctness of the abstract network layer, not proving that arbitrary C code, arbitrary compilers, or arbitrary machine code are safe. The input domain must satisfy total order, and the comparator must be strictly equivalent to min/max. As for GCC, Clang, SIMD instructions, integer overflow, NaN, and undefined behavior, those are things for the next layer of verification to handle."

Jiang Lin did not linger too long on this green victory; he skillfully operated the mouse, returned to the previous directory level, and switched to the second folder.

"Now that the cornerstone of correctness has been welded shut, next comes the half that you truly find a headache during engineering implementation: how to achieve ultimate speed."

Chen Qiming's attention was instantly drawn over.

What was displayed on the screen was no longer a simple test script, but a framework skeleton personally built by Jiang Lin.

To ordinary people, that might just be a bunch of boring English directories and hierarchical structures.

But to a veteran like Chen Qiming who had been steeped in system architecture for decades, merely glancing at the directory dependency relationships of the entire project made his pupils contract involuntarily.

Because this superoptimization framework aimed at finding the optimal instruction arrangement was cleanly partitioned into three mutually independent yet tightly interlocking levels.

"The first layer, I call it the candidate generator."

Jiang Lin's mouse pointer hovered over a module named Generator.

"Its sole responsibility is to continuously spit out various possible sorting network topology structures outward according to rules. It is responsible for adding comparators, performing preliminary redundancy pruning, and carrying out equivalent state deduplication. This layer operates entirely in abstract mathematical space, having not the slightest bit of relation to what machine the code will eventually run on."

"The second layer is the Zero-One validator we just demonstrated, playing the role of an absolutely cold gatekeeper in this system. Among the candidate networks spat out by the underlying search algorithms, there will inevitably be a large handful of garbage structures that run extremely fast but whose logic is actually wrong. This layer looks at no performance metrics, only looking at correctness, executing all those shoddy products on the spot without missing a single one."

"As for the third layer, which is the cost evaluation engine," Jiang Lin slowed down his speaking pace, weighting his tone, "its task is to score those surviving correct candidate networks and judge which one will run faster in actual operation."

"And this layer is the only part in the entire framework that is bound to specific underlying physical hardware."

Jiang Lin turned his head and said to the three of them.

"The most crucial thing is, it is hot-swappable."

Hearing the word "hot-swappable", Chen Qiming's breathing frequency visibly grew heavier by a fraction.

"Swappable, how is that understood?" Qiao Yue's engineering experience was still shallow, and his brain's operating speed hadn't quite kept up with this leaping architectural design.

"It means that if our target environment changes to a machine with a different microarchitecture, we only need to dismantle and replace this backend cost evaluation board separately."

Jiang Lin patiently explained.

"If what we feed the evaluation engine is the latency table and port contention model of a certain generation of Intel architecture, it will score according to Intel's temperament. If we switch to an ARM architecture model, it will evaluate according to ARM's throughput upper limit. As for the search and verification logic of the first two layers, not even a single punctuation mark of code needs to be modified."

The air in the laboratory seemed to be instantly sucked dry.

Until Pei Li walked over.

"Cutting open the architecture is not difficult; what's difficult is not bleeding after cutting it open."

He walked to the front of the screen and pointed at the second-layer validator.

"What your Zero-One validator proves is the compare-exchange network. But the things spat out by my superoptimizer don't necessarily honestly grow into comparators. It might be cmov, it might be blend, it might be pminsd, or it might save an instruction relying on some undefined behavior."

"How do you prove that these dirty things are truly equivalent to the compare-exchange in your abstract layer?"

"Therefore, the Zero-One validator is only the first gate."

Jiang Lin picked up a marker and wrote five lines of words on the whiteboard beside him.

Abstract Network.

Primitive Semantics.

Source Code Implementation.

Binary Equivalence.

Microarchitecture Cost.

"What you have been stuck on for three years is not a solid iron slab, but five layers of things mixed together. We have to take it apart first."

Qiaoyue stood by with his mouth wide open, his gaze shifting back and forth between Pei Li and Jiang Lin.

Until this very moment, he realized concretely that the teenager in front of him, who always wore a calm expression, was definitely far more than just exceptionally good at mathematics.

He also possessed a terrifying intuition for performing dimensionality-reduction deconstruction on complex engineering.

"Teacher Chen, before we start the actual search, I must first confirm an engineering constraint with you." Jiang Lin did not immerse himself in the others' amazement, but quickly pulled the topic back to the most hardcore practical level, "For the sort5 required by your team, is its core demand single-shot latency-sensitive, or batch throughput-sensitive?"

Chen Qiming was slightly taken aback upon hearing this.

Qiaoyue almost subconsciously chimed in, "Isn't fast just fast? Naturally, if the time is shorter, it's fast. Does this still divide into..."

Halfway through his sentence, Qiaoyue stuttered to a halt, vaguely sensing that he might have exposed his underlying cognitive blind spot.

"The two are completely different on modern microarchitectures."

The one who finished Qiaoyue's sentence was Pei Li, his tone carrying a complex sense of emotion.

"If you only sort a group of five numbers at a time and require the shortest time from input to output for this set of data, then what you are pursuing is the lowest latency. But if you are facing massive amounts of data, such as sorting hundreds of millions of groups a day, your goal is how many groups of data can be processed per unit of time. On modern CPU's complex out-of-order execution and superscalar pipelines, these two goals are often mutually exclusive."

Pei Li took a deep look at Jiang Lin.

Even within their research group, which specialized in system underlying layers, this question was rarely discussed seriously before writing code.

When facing the word optimization, everyone defaulted to a single dimension of fast.

Then they subconsciously obsessed over the absolute number of comparators and fussed over writing one less assembly instruction.

However, on modern processors with multiple ALU ports, complex branch prediction, and reorder buffers, the minimum number of instructions did not mean the highest throughput.

"We are going to run in a batch processing scenario, and what we value is ultimate throughput." Chen Qiming did not hesitate at all and directly set the tone.

"That makes things easier."

Jiang Lin nodded, opened the configuration file of the cost-evaluation backend, and loaded the hardware port contention model data of machine A previously provided by Chen Qiming.

"I explicitly set the search target to maximizing throughput, and then ran a directional search within a restricted space under this specific model."

Jiang Lin did not initiate a full-scale search.

Searching the entire instruction state space globally was a colossal project that would take decades to grind through slowly in the computational Wasteland without the support of a computing power cluster.

He simply made this three-layer architecture run for less than five minutes within an extremely narrow range that had been rigorously pruned mathematically.

After the workstation's cooling fan emitted a short and hurried roar, rows of freshly baked candidate results were spit out on the screen.

"Teacher Chen, take a look."

Jiang Lin brought up the built-in comparison tool and displayed the two pieces of code side by side.

"Among the first tier here, there is a sorting network whose topology is almost identical to the version your team spent months manually tuning. This result first confirms one thing: your team's craftsmanship in underlying optimization has no flaws whatsoever. Within the boundaries that humans can reach with intuition and experience, you have indeed touched upon the baseline where the number of comparators is optimal."

Hearing this, Chen Qiming's tense expression finally relaxed a lot.

"However, please look at this one." Jiang Lin's mouse slid down and clicked on another candidate solution with a slightly higher score, "This scheme also has nine comparators, not a single one more than yours, nor any fewer. Yet it arranges the instruction layout order of these nine comparators in a seemingly counter-intuitive staggered arrangement. This staggering just happens to avoid the congestion of ALU port resources on machine A during specific cycles."

"On machine A, and only under machine A's microarchitecture, its ultimate throughput is less than three percent faster than the version you manually tuned."

Three percent.

In everyday software development, this is a number so small it is almost not worth mentioning and can easily be drowned out by environmental noise.

However, Pei Li said nothing, brought up his own terminal environment on the secondary screen beside him, and copied the candidate code searched out by Jiang Lin, which didn't even have any comments added, into it.

He personally hooked up the compiler, turned on the highest level of optimization options, connected to Linux's built-in perf performance analysis tool, held his breath, and ran the benchmark tests three times in a row.

Then he locked the CPU affinity, turned off Turbo Boost fluctuations, pinned the governor to performance, warmed up the cache, and ran fifty groups consecutively with perf stat -r50.

He stared at the columns of numbers for cycles, instructions, uops issued, and branch-misses for a long time.

After thirty groups, the trend was still there.

After fifty groups, the confidence interval was not pushed back to the original version.

That less than three percent difference finally stood out from the noise.

"Five minutes?" Pei Li pointed at the equipment on the table, his voice somewhat hoarse, "This is just the result of running on an ordinary machine for five minutes?"

"Mm, less than five minutes, because strict pruning conditions were set." Jiang Lin replied calmly.

Chen Qiming let out a long sigh, "An automated restricted search that only ran for five minutes, relying on targeted hardware models, forcibly outperformed the version our team spent over half a year hand-crafting on a use case we had studied inside and out."

Qiaoyue on the side had completely lost the ability to organize language at this moment.

But Pei Li was, after all, a veteran who had experienced countless architectural failures.

After a brief shock, his eyes flickered, as if he keenly captured some hidden flaw from this near-miraculous demonstration.

"Wait, sort5 is too small after all. The permutations and combinations of five elements are limited anyway, and relying on exquisite restricted search, you can indeed muddle through in a short time."

Pei Li stared closely into Jiang Lin's eyes, his speaking speed accelerating.

"However, what Director Chen truly wants to roll out is integrating this sorting logic into our entire set of underlying data processing kernels. We need to sort eight numbers, sixteen numbers, or even more at once. You know better than I do that once the number of elements increases, the state space of the underlying network explodes exponentially. Once the computing power of the restricted search hits that exponential high wall, it simply cannot hold up."

This was the last possible collapse crisis Pei Li could think of at the system architecture level and on top of this elegant framework.

However, Jiang Lin did not reveal any embarrassment of being exposed.

Instead, he nodded approvingly, as if all this had long been within his deductive sandbox.

"You hit the nail on the head, so the three percent performance improvement demonstrated just now is exclusive to machine A. If the same underlying code is thrown onto machine B or machine C with different microarchitectures, this advantage will most likely vanish completely, and negative optimization might even occur."

Jiang Lin continued along with Pei Li's words.

"The true value of this three-layer architecture does not lie in generating some magical piece of code at this moment, but in the cost-evaluation backend that can be redirected at any time."

Facing two senior system researchers, Jiang Lin's tone still didn't have much fluctuation.

"In addition, the numbers actually measured by Senior Brother Pei using perf just now inherently carry a lot of environmental noise in a real, complex operating system environment. Cache hit rate fluctuations and operating system scheduling interrupts will cause the same piece of code to run fast one time and slow another. In future full-scale searches, the cost model must undergo repeated simulation and sampling, taking the most robust statistical median, otherwise the fastest thing searched out by the algorithm is just a fortress built on a beach."

"Of course, there is also the point you mentioned just now, the exponential explosion problem of the state space when the scale of N becomes larger."

Jiang Lin looked at Pei Li, avoiding this technical blind spot not at all.

"Restricted search and the Zero-One Principle can indeed easily handle sort5, but they definitely cannot cope with monsters of the magnitude of sort16. To make this framework run systematically disruptive results on your huge and complete set of microkernels, we need more aggressive pruning algorithms, cost models closer to the physical characteristics of silicon wafers, and unprecedented heuristic search strategies. From the front end to the back end, every single board needs to be repolished."

"This part is a tough bone to crack and cannot be achieved overnight. I need some time to build new mathematical tools."

Jiang Lin drew a period to this presentation with a tone stating objective facts.

Pei Li opened his mouth slightly, a low airy sound coming from his throat.

The killer move he had originally prepared, trying to save the face of an underlying engineer, had apparently been anticipated by the other party all along.

The limitations of physical boundaries, the random noise of performance testing, and that seemingly unreachable mountain of exponential computation.

Jiang Lin did not omit a single one, frank to the point of being admirable.

Chen Qiming stared fixedly at Jiang Lin standing in front of the desk.

This eighteen-year-old teenager, in the past half hour, with an unquestionable green PROVED and a piece of machine code squeezing out three percent performance, almost made this veteran who had worked on underlying architecture for most of his life waver in his team's long-standing craftsmanship and beliefs.

However, at a moment of achieving such an overwhelming advantage, not only did the other party not seize the right to speak entirely, nor did he boast about future prospects grandly.

On the contrary, he calmly analyzed the existing boundaries of this tool, the objective noise of the hardware backend, and the uncrossed mountain of mathematics to them one by one as if walking on thin ice.

In this impetuous academic circle, people who know how to show off skills are as numerous as crucian carp crossing a river.

But people who know how to rein in their brilliance steadily at the moment it shines the brightest, in the places where they should restrain themselves the most, are extremely rare.

"I understand."

Chen Qiming nodded heavily, the expression on his face unprecedentedly solemn and grave.

"The significance of this matter is too great; we cannot just make a private decision between the two of us in this enclosed office. Regarding subsequent authorship rights, patent ownership, and joint research and development processes, we must go through the most formal and rigorous cooperation channels."

"Mm." Jiang Lin expressed agreement, "Teacher Chen can lead the administrative process of the Department of Computer Science on your side. My current temporary visitor status is affiliated with the School of Physics and is under the charge of Teacher Lu. We will report to the departments what needs to be reported, and sign the confidentiality and cooperation agreements step by step clearly."

He paused slightly and added, "I can first authorize the source code of the Zero-One verification fixture to you for internal scientific research verification. It only contains the 0-1 test of the five-input sorting network, log output, and interface templates, and does not contain the candidate generator, nor does it contain the complete MPS search framework. The scope of authorization, whether it is open-sourced, and whether it is used for papers and subsequent commercial projects will be written into the agreement."

"As for that mountain piled up by exponential explosion?"

Jiang Lin casually turned off the test screen on the workstation, unplugged the black USB flash drive, and his tone was as calm as water.

"Give me some time."

Qiaoyue, who had been unable to get a word in and was flushed with frustration, didn't come back to his senses until this moment as if waking from a big dream.

He rushed forward two steps eagerly, took out his phone, and said, "Senior Brother Jiang, can we add each other on WeChat? If there's anything I don't understand about framework compilation in the future, can I consult you at any time?"

Pei Li watched his junior brother's appearance from the side, and couldn't help letting out a soft scoff.

Afterwards, he silently turned back around, pulled out the candidate code searched out by Jiang Lin in five minutes on the terminal once again, stared at those unconventional comparative assembly instructions, and looked at them for the third time.

Prev Next

🔊 Text To Speech

Listen while reading

Ready