Chen Zhuo paused, then added, "Vector-sparse matrix multiplication has a time complexity of O(N). Even if someone has ten thousand connections, a computer can perform this kind of one-dimensional array multiplication in less than a millisecond."
In the internet cafe, Chu Ge had already bitten the candy clean off the stick.
The hard plastic hit his teeth, and he snapped back to reality, flinging the stick to the ground.
His eyes were glued to the instant noodle lid stained with red chili oil in front of him.
On it were written two somewhat messy lines of formulas.
The database deadlock had plagued the Capital City startup for two full weeks, a problem several top students from Qinghua’s Department of Computer Science had deemed an unsolvable hardware bottleneck.
Yet, coming from this twelve-year-old boy, a few basic linear algebra concepts had just smashed it to smithereens.
"I get it."
Chu Ge’s voice was trembling slightly.
"Ditch the relational queries. Pull all the relation tables out and maintain a sparse matrix in memory. Run all queries as vector multiplications in memory. Once you get the result, you just use the user ID to pull the avatar and name from the database."
"Right," Chen Zhuo replied.
"But there’s a problem."
Chu Ge’s programmer mindset quickly found a flaw.
"A knows B, B knows C, and C knows A. That’s a cycle in graph theory. If the vectors keep multiplying, won’t it create an infinite loop and burn out all the computing power?"
"Chu Ge."
Chen Zhuo sighed on the other end of the line, a hint of exasperation in his tone.
"This is an engineering problem, not a mathematical proof. In the results from the vector multiplication, for any value greater than 0, just use a hash table to record the ID. The next time you multiply, if you encounter an ID you’ve already recorded, just skip it."
Chen Zhuo gently shook his head.
"You’re a coder. Don’t expect a mathematical formula to calculate how many squares of toilet paper you need to wipe your ass. Use some of your programmer’s common sense, would you?"
Hearing the teasing tone over the phone, Chu Ge suddenly broke into a wide grin.
"Alright. I owe you one. This time, it’s on me."
Chu Ge folded the noodle lid twice and carefully tucked it into his pocket.
"When I get back to Keda after the New Year, I’ll treat you to a month’s worth of stir-fry from the cafeteria. I’m hanging up now. I need to hurry up and write this low-level memory daemon."
A dial tone buzzed from the receiver before Chen Zhuo could even reply.
Chen Zhuo put down the phone, shook his head, a slight smile on his lips.
He turned and walked to the kitchen to get a bowl and chopsticks, ready to eat dinner.
「...」
Over a thousand kilometers from Zeyang City, in the Capital City.
Inside a dilapidated residential building near Zhongguan Village.
The room was dark, lit only by the pale glow of three or four monitors. Outside, the occasional flash of brilliant fireworks illuminated a floor littered with cigarette butts and leftover takeout containers.
Wang Xing was wrapped in a thick cotton jacket, slumped in his computer chair. His eyes were bloodshot, glued to the backend log on the screen.
They wanted to build a true real-name campus social networking site in this wild west era of the internet. The idea was brilliant. Wang Xing and his partners had even managed to secure an angel investment of several hundred thousand with just a PowerPoint presentation.
But a technical bottleneck had them dead in the water.
Tomorrow was the third day of the Lunar New Year, and their investor was demanding a system demo that could support five hundred users online simultaneously.
Wang Xing hadn’t slept in three days.
As soon as concurrency rose, the database queries for the core "friend of a friend" feature would crash the entire system like an avalanche.
The MSN icon in the bottom-right corner of the screen suddenly started blinking.
Wang Xing’s bloodshot eyes twitched. He grabbed the mouse and clicked it open.
It was Chu Ge, the freakishly talented hacker from Keda, all the way in Huizhou, whom he’d roped in as free technical support.
"Old Chu, save your energy."
Wang Xing typed a line and sent it, his fingers a little stiff.
"We tried adding a cache, tried building an index. Nothing works. A relational database can’t handle this kind of multi-level network query. The hardware can’t take it."
A few seconds later, Chu Ge sent a compressed file.
It was less than 20KB.
Immediately after, a message from Chu Ge popped up.
"Delete all your previous relational query code. Run this C-language daemon on the server’s backend."
Wang Xing froze for a moment.
"What is this?"
"A memory-level sparse matrix multiplication tool."
Chu Ge’s reply was simple.
"Just export your relation table as a plain text file and feed it to this. From now on, for all friend queries, don’t go through the database. Just send a command to this process. It’ll do the calculations in memory and return an array of friend IDs to you."
Wang Xing stared at the message, completely baffled.
But he was at his wit’s end. It was a long shot, but he had nothing to lose.
He accepted the file, unzipped it, and dragged the source code into his compiler for a quick look.
The moment he saw it, a cold sweat broke out on Wang Xing’s back.
The code was extremely concise. There were no library files for database connections, only low-level memory pointer operations and a few one-dimensional array loop multiplications that he couldn’t quite understand.
There wasn’t a single SQL statement inside.
Wang Xing took a deep breath. He uploaded the compiled executable to the test server’s backend, then fed it tens of thousands of lines of test relational data.
The process started silently, using less than fifty megabytes of memory.
"Run a stress test."
Wang Xing turned his head and shouted to Wang Huiwen, who was slumped over next to him, half-asleep.
Wang Huiwen groggily rubbed his eyes and typed a stress test command into the keyboard.
"Simulating five hundred concurrent requests, three-degrees-of-separation friend query."
Reading settings
Size
18
Font
Alignment
Theme
Spacing
1.7
Width
Original text
Progress marks
My IQ Increases Year by Year — Chapters
1
Chapter 1
2
Chapter 2
3
Chapter 3
4
Chapter 4
5
Chapter 5
6
Chapter 6
7
Chapter 7
8
Chapter 8
9
Chapter 9
10
Chapter 10
11
Chapter 11
12
Chapter 12
13
Chapter 13
14
Chapter 14
15
Chapter 15
16
Chapter 16
17
Chapter 17
18
Chapter 18
19
Chapter 19
20
Chapter 20
21
Chapter 21
22
Chapter 22
23
Chapter 23
24
Chapter 24
25
Chapter 25
26
Chapter 26
27
Chapter 27
28
Chapter 28
29
Chapter 29
30
Chapter 30
31
Chapter 31
32
Chapter 32
33
Chapter 33
34
Chapter 34
35
Chapter 35
36
Chapter 36
37
Chapter 37
38
Chapter 38
39
Chapter 39
40
Chapter 40
41
Chapter 41
42
Chapter 42
43
Chapter 43
44
Chapter 44
45
Chapter 45
46
Chapter 46
47
Chapter 47
48
Chapter 48
49
Chapter 49
50
Chapter 50
51
Chapter 51
52
Chapter 52
53
Chapter 53
54
Chapter 54
55
Chapter 55
56
Chapter 56
57
Chapter 57
58
Chapter 58
59
Chapter 59
60
Chapter 60
61
Chapter 61
62
Chapter 62
63
Chapter 63
64
Chapter 64
65
Chapter 65
66
Chapter 66
67
Chapter 67
68
Chapter 68
69
Chapter 69
70
Chapter 70
71
Chapter 71
72
Chapter 72
73
Chapter 73
74
Chapter 74
75
Chapter 75
76
Chapter 76
77
Chapter 77
78
Chapter 78
79
Chapter 79
80
Chapter 80
81
Chapter 81
82
Chapter 82
83
Chapter 83
84
Chapter 84
85
Chapter 85
86
Chapter 86
87
Chapter 87
88
Chapter 88
89
Chapter 89
90
Chapter 90
91
Chapter 91
92
Chapter 92
93
Chapter 93
94
Chapter 94
95
Chapter 95
96
Chapter 96
97
Chapter 97
98
Chapter 98
99
Chapter 99
100
Chapter 100
101
Chapter 101
102
Chapter 102
103
Chapter 103
104
Chapter 104
105
Chapter 105
106
Chapter 106
107
Chapter 107
108
Chapter 108
109
Chapter 109
110
Chapter 110
111
Chapter 111
112
Chapter 112
113
Chapter 113
114
Chapter 114
115
Chapter 115
116
Chapter 116
117
Chapter 117
118
Chapter 118
119
Chapter 119
120
Chapter 120
121
Chapter 121
122
Chapter 122
123
Chapter 123
124
Chapter 124
125
Chapter 125
126
Chapter 126
127
Chapter 127
128
Chapter 128
129
Chapter 129
130
Chapter 130
131
Chapter 131
132
Chapter 132
133
Chapter 133
134
Chapter 134
135
Chapter 135
136
Chapter 136
137
Chapter 137
138
Chapter 138
139
Chapter 139
140
Chapter 140
141
Chapter 141
142
Chapter 142
143
Chapter 143
144
Chapter 144
145
Chapter 145
146
Chapter 146
147
Chapter 147
148
Chapter 148
149
Chapter 149
150
Chapter 150
151
Chapter 151
152
Chapter 152
153
Chapter 153
154
Chapter 154
155
Chapter 155
156
Chapter 156
157
Chapter 157
158
Chapter 158
159
Chapter 159
160
Chapter 160
161
Chapter 161
162
Chapter 162
163
Chapter 163
164
Chapter 164
165
Chapter 165
166
Chapter 166
167
Chapter 167
168
Chapter 168
169
Chapter 169
170
Chapter 170
171
Chapter 171
172
Chapter 172
173
Chapter 173
174
Chapter 174
175
Chapter 175
176
Chapter 176
177
Chapter 177
178
Chapter 178
179
Chapter 179
180
Chapter 180
181
Chapter 181
182
Chapter 182
183
Chapter 183
184
Chapter 184
185
Chapter 185
186
Chapter 186
187
Chapter 187
188
Chapter 188
189
Chapter 189
190
Chapter 190
191
Chapter 191
192
Chapter 192
193
Chapter 193
194
Chapter 194
195
Chapter 195
196
Chapter 196
197
Chapter 197
198
Chapter 198
199
Chapter 199
200
Chapter 200
201
Chapter 201
202
Chapter 202
203
Chapter 203
204
Chapter 204
205
Chapter 205
206
Chapter 206
207
Chapter 207
208
Chapter 208
209
Chapter 209
210
Chapter 210
211
Chapter 211
212
Chapter 212
213
Chapter 213
214
Chapter 214
215
Chapter 215
216
Chapter 216
217
Chapter 217
218
Chapter 218
219
Chapter 219
220
Chapter 220
221
Chapter 221
222
Chapter 222
223
Chapter 223
224
Chapter 224
225
Chapter 225
226
Chapter 226
227
Chapter 227
228
Chapter 228
229
Chapter 229
230
Chapter 230
231
Chapter 231
232
Chapter 232
233
Chapter 233
234
Chapter 234
235
Chapter 235
236
Chapter 236
237
Chapter 237
238
Chapter 238
239
Chapter 239
240
Chapter 240
241
Chapter 241
242
Chapter 242
243
Chapter 243
244
Chapter 244
245
Chapter 245
246
Chapter 246
247
Chapter 247
248
Chapter 248
249
Chapter 249
250
Chapter 250
251
Chapter 251
252
Chapter 252
253
Chapter 253
254
Chapter 254
255
Chapter 255
256
Chapter 256
257
Chapter 257
258
Chapter 258
259
Chapter 259
260
Chapter 260
261
Chapter 261
262
Chapter 262
263
Chapter 263
264
Chapter 264
265
Chapter 265
266
Chapter 266
267
Chapter 267
268
Chapter 268
269
Chapter 269
270
Chapter 270
271
Chapter 271
272
Chapter 272
273
Chapter 273
274
Chapter 274
275
Chapter 275
276
Chapter 276
277
Chapter 277
278
Chapter 278
279
Chapter 279
280
Chapter 280
281
Chapter 281
282
Chapter 282
283
Chapter 283
284
Chapter 284
285
Chapter 285
286
Chapter 286
287
Chapter 287
288
Chapter 288
289
Chapter 289
290
Chapter 290
291
Chapter 291
292
Chapter 292
293
Chapter 293
294
Chapter 294
295
Chapter 295
296
Chapter 296
297
Chapter 297
299
Chapter 299
301
Chapter 301
302
Chapter 302
303
Chapter 303
304
Chapter 304
305
Chapter 305
306
Chapter 306
Comments
Log in to leave a comment.