Dust and Stars - 1992 | Chapter 154 | Queue and Thresholds | English
The cursor blinked rhythmically against the black background of the terminal. Like a heartbeat. Lin Chen lifted his left foot off
Chapter 154: Queue and Thresholds
The cursor blinked rhythmically against the black background of the terminal. Like a heartbeat.
Lin Chen lifted his left foot off the computer case and let his heel touch the floor lightly. Numbness crept up his calf, like a strip of coarse cloth soaked through and wrapped around the muscle, and a dull ache rose from the joints. He drew a deep breath and forced his attention back onto the screen. Twenty minutes. Time had been cut into executable segments: in the first minute, locate the entry point of the polling logic; by the third, strip out the CAS retry loop in the lock-free structure; by the seventh, introduce a blocking mechanism, turning empty spinning into sleep-and-wake behavior.
His fingers tapped at the keyboard. The rhythm was not fast, but every keystroke landed with purpose. He did not need elegant architecture, only a consumer side that could run steadily at low queue depth. Busy waiting would drain CPU cycles dry, while event-driven logic would let the thread yield control voluntarily when data was not ready. The kernel scheduler would handle the rest.
Minute five. The code skeleton was in place. Compile.
The gcc progress bar finished, and the terminal threw out a single line of error text: undefined reference to 'futex_wake'. Link failure. He had forgotten the wrapper layer. The underlying C library did not expose that interface directly; he would have to wrap it with syscall, or switch to pthread_cond_wait. There was no time to rewrite the abstraction. He switched back to the code at once and replaced it with syscall(SYS_futex, ...). Compiled again. It passed.
Minute eight. First run.
The program started. The progress bar rolled to 12%. Then it froze. The terminal stopped printing logs. CPU utilization dropped sharply from 45% to 3%.
Deadlock.
Lin Chen's breathing did not change. He pulled up strace to trace the process. The output stream was full of futex(0x..., FUTEX_WAIT_PRIVATE, 2, NULL). The wake-up signal had not been delivered correctly. The problem lay in the boundary check when the queue was full. After the producer wrote its data, one wake call had been missed. He added the wake-up logic at line 142. Saved. Compiled.
Minute thirteen. Second run.
The progress bar started again. This time there was no stutter. The terminal began spitting out throughput metrics in dense succession: IOPS: 14200 | Latency: 0.8ms | Queue Depth: 16. The latency curve stayed smooth, without spikes. CPU usage held steady at 28%. Idle cycles were being released properly.
Lin Chen leaned back in the chair. A sharp stab of pain came from his left foot, like a fine needle driving into the ankle bone. He closed his eyes and waited for the pain to pass. When he opened them again, the figures on the screen had already finished running through the preset dataset of eight thousand entries. Final result: average latency 0.72 ms, peak 1.1 ms. It met the acceptance threshold.
Zhao Jianguo had been standing by the server rack the entire time. Arms folded, his eyes never leaving the screen. When he heard Lin Chen press Enter, he walked over and bent down to look at the log. For about ten seconds, he said nothing. In the machine room there was only the low-frequency hum of the cooling fans and the occasional click of the server hard drives.
"It passed," Zhao Jianguo said, straightening up, his tone flat. "The blocking strategy at low queue depth is clean. No memory leaks left hanging. Young man, understanding hardware's temper matters more than understanding syntax."
Lin Chen nodded. He said nothing. He pulled out the flash drive, cleaned up the temporary files, and shut down the terminal. Every movement was slow, because each one reminded him, through the swelling in his left foot, of where his body's limits were. He braced himself against the edge of the desk to stand, putting his weight on the right foot and only touching the ground lightly with the left.
"Engineer Li left a message before he went," Zhao Jianguo said. He took a stiff paper card from his pocket and set it on the machine platform. "Intern subsidies are paid according to project milestones. This phase is settled. The money will hit your card next Wednesday. Check the amount against your text message."
Lin Chen glanced at the card. On it were the machine room access permissions and the internal settlement number. He did the calculation in his head. The money would be just enough for Xiaoman's sodium valproate for two months, plus the dormitory's utilities for the next quarter. The numbers ran through his mind and fit exactly. No surplus, but enough to cover the bottom line.
"Thank you, Engineer Zhao," he said.
"No need," Zhao Jianguo waved a hand. "The code runs because you worked with its nature instead of against it. SSDs aren't mechanical drives. Random reads and writes are fast, but when the queue gets deep, the controller slows down. By switching to blocking, you avoided the hardware's weakness. Next week this goes into production. The cluster kernel is 2.6.32. Your futex logic will need to stay compatible two layers down. The old system's thread scheduler has bugs; under high concurrency it can lose wake-up signals. Go back and stress-test it. I want the report before Friday."
Lin Chen memorized it. 2.6.32. A ten-year-old kernel. For the sake of stability, enterprise servers often did not upgrade the underlying system. That meant he could not use new features. He would have to go back to more primitive synchronization primitives, or write his own compatibility layer. The difficulty doubled, but the path was clear. He was used to breaking the unknown down into the known.
"Understood."
Zhao Jianguo gave him a look, his eyes resting for a moment on Lin Chen's slight limp in the left foot, but he asked no questions. "The machine room locks at ten-thirty. Head back early. Don't wear your body out. The code won't run a second version for you."
Lin Chen packed up his bag and got to his feet. As he walked out of Machine Room B, the sound-activated lights in the corridor came on one after another. The early autumn wind poured in through a half-open window, carrying the faint scent of osmanthus trees by the sports field. Very faint. He walked slowly, planting every step firmly. The stairs were a little high, so he had to shift his center of gravity and let his right leg pull his body upward. Sweat had soaked through the shirt on his back, leaving it plastered to his skin, cold and clammy.
By the time he reached the dormitory building, the sky was fully dark. The streetlights stretched his shadow long across the ground. He took out his phone, and the screen lit up. A bank text message popped up right on time: Your account ending in 7749 has received RMB 1,800.00. Balance: RMB 1,835.30.
He stared at the string of numbers for three seconds. Then he opened his contacts and called the village clinic. It rang five times before someone picked up. Doctor Wang.
"Hello, Lin Chen."
"Doctor Wang, can Xiaoman's medicine be renewed for another two months? I'll transfer the money tomorrow."
"Of course, of course. I'll prepare the same dosage as last time. How's your foot? Last time I saw you, even walking looked difficult."
"Much better. Thank you."
He hung up. Standing in the shadows beneath the dormitory building, he looked up at the unlit window on the fourth floor. The wind was a little cold. He slipped the phone back into his pocket and pushed open the unit door. The stairwell bulb was broken, and he made his way up in the dark. Three steps, pause, switch feet. Three more. The key went into the lock. Turn. The door opened.
On the desk lay that copy of Understanding the Linux Kernel. It was open to the chapter on process scheduling. He sat down and switched on the desk lamp. A circle of light fell across the page. He turned to the appendix with the scheduler source code for kernel 2.6.32. His finger traced the C-language structures there. struct task_struct. runqueue. wake_up_process.
He pulled out a red pen and wrote the first line of his analysis in the margin: The compatibility layer must work around the CFS scheduler's lost-wakeup defect, downgrading to a semaphore + spinlock scheme. The stress-test environment must simulate cache-coherency delays on older CPUs.
The pen tip paused. He lifted his head and looked out the window. The city's neon blurred together in the distance into a band of indistinct light. No stars. Only dust settling slowly under the lamps.
He lowered his head and kept writing. The second line, the third. The chain of logic stretched across the paper. Like a road with no end.
His phone vibrated once at the corner of the desk. The screen lit up. It was a text from an unfamiliar number: Student Lin Chen, the Provincial Science and Technology Department's Spark Program industry-university-research matchmaking conference will be held next Saturday at the Municipal Convention and Exhibition Center. Your name is on your university's Computer Science Department recommendation list. Please bring your project's technical white paper. Reply upon receipt.
Lin Chen stared at the line of text. His fingers rubbed unconsciously along the pen barrel.
He set the pen down and picked up the phone. His thumb hovered above the screen. He did not reply immediately.
He opened the computer first and created a new folder. He named it Spark_Technical_White_Paper.
Only then did he type two words: Received.
The light of the screen shone across his face. Quiet. Restrained. Like a stone sinking to the bottom of the water.
The night was still long. The code was not finished. The road still had to be walked one step at a time.
More from WayDigital
Continue through other published articles from the same publisher.
Comments
0 public responses
All visitors can read comments. Sign in to join the discussion.
Log in to comment