Blog/Two Faster Clocks for a Hardware Priority Queue
FrontierCS 2Case studyOctober 18, 2026

Two Faster Clocks for a Hardware Priority Queue

BBQ, an NSDI 2024 circuit, picks the next packet a network card sends. Gemini 4 Argon and Claude Opus 5.5 each gave it a faster clock than its authors did, one with the same memory and one with registers in its place. We build the circuit up from a 16-priority example to show both.

By FrontierCS 2 Team
Solution checked by Siddhant RayUniversity of Chicago

Gemini 4 Argon and Claude Opus 5.5 each ran the BBQ task once in FrontierCS 2. Both gave a hardware priority queue a faster clock than its authors did. Both removed the same wait. Each level of the queue reads a counter from memory, and the clock must leave room for that read. Gemini 4 Argon kept every memory and made the choice that follows the read before the value lands. Its circuit handles up to 1.56 times the operations per second of the human reference, with about the same logic. Claude Opus 5.5 took the counters out of memory. Its circuit handles up to 1.84 times as many, with up to 16 times the logic. Of the twelve models on the leaderboard, these two and GPT-6.1 Sol passed.

The Task

FrontierCS 2 removes the core of a paper’s released code, and an agent writes it back. The authors’ code is the human reference. A run passes only if its final version beats it on every metric of every hidden workload.

BBQ is a priority queue built as a circuit, by Atre, Sadok and Sherry at NSDI 2024 [1]. A network card or a switch needs such a queue to schedule packets. Each packet gets a priority, and the queue must hand out the best one next, millions of times a second. On an FPGA, BBQ reports three times the packet rate of similar hardware queues [1].

The task keeps the circuit around the queue and removes the logic of its tree levels. That logic is a Python program that writes the circuit, and the agent writes it back. The judge checks every answer on nine workloads at five tree sizes. It then measures two speeds on each workload: operations per second, and the latency of the slowest operation. A pass needs both to beat the human reference on every workload.

A Queue Built from Bitmaps

Take 16 priorities, 0 to 15, with 0 the best. BBQ keeps them in a tree of 4-bit bitmaps, as Figure 1 shows. The bottom level has four rows of four bits, one bit per priority. A bit is 1 when a packet of that priority waits. The top level has a single row, and its bit i is 1 when row i below holds a 1.

Each bit also has a counter of the packets below it. In Figure 1 the queue holds two packets of priority 1, one of priority 2 and two of priority 9.

To remove the best packet, the circuit follows the first 1 at each level. At the top it finds bit 0, so it goes to row 0. In row 0 it finds bit 1: priority 1. It then subtracts one from each counter on its way.

A bit turns to 0 when its counter does. The first removal leaves one packet of priority 1, so no bit changes. The second takes the last one, and bit 1 of row 0 turns to 0. The third removal must then find priority 2, and it empties row 0. Each removal must know whether a count was 1. The next removal comes one cycle later and must see the result.

BBQ ON 16 PRIORITIESTop level13001200Bottom level00121100row 0priorities 0 to 300000000row 1priorities 4 to 700120000row 2priorities 8 to 1100000000row 3priorities 12 to 15the first 1 at each level: the best packet, priority 1Under each bit, its counter: the packets below it.THREE REMOVALS1Priority 1.Counters 2 to 1 and 3 to 2.No bit changes.2Priority 1 again.Counter 1 to 0: bit 1 of row 0turns to 0.3Priority 2.Bit 2 of row 0 turns to 0, andwith it bit 0 of the top level.Each removal must know whether acount was 1, and the next must see it.
Figure 1. BBQ on 16 priorities, with five packets waiting. A removal follows the first 1 at each level and subtracts one from each counter on its way. The second removal of priority 1 empties its bucket, and the third must see that.

How the Clock Is Set

A circuit works in ticks of a clock. Between ticks, values wait in registers. In each tick, values leave the registers, pass through logic and must settle in the next registers. The clock period is the time of the slowest such stretch.

The task computes the period from the circuit with a fixed model. Synthesis cuts the logic into lookup tables, the basic gate of an FPGA. Each lookup table on a stretch costs 500 picoseconds, and every period carries a fixed 300 ps:

\[\text{period} = 300 + 500\,n \ \text{ps},\]

where \(n\) is the number of lookup tables on the slowest stretch. A stretch that starts at a memory read costs 1,000 ps more, as Figure 2 shows.

THE CLOCK PERIOD UNDER THE TASK MODELregisterLUTLUTLUTregister300 + 3 × 5001,800 psmemoryblockLUTLUTLUTregister300 + 1,000 + 3 × 5002,800 psA lookup table (LUT), the basic gate of an FPGA, costs 500 ps. A stretch that starts at a memory read costs 1,000 ps more.
Figure 2. Two stretches between clock ticks under the task's model. Three lookup tables after a register take 1,800 ps. The same three after a memory read take 2,800 ps.

The period sets the speed. A design finishes some number of operations per cycle, and its operations per second is that number over the period. Every design in this study finishes about 0.68 operations per cycle, so the period decides.

No design can go below 1,800 ps. The stage that reads the priority buckets is fixed, outside the agent’s part. It reads a memory and passes one lookup table: 300 + 1,000 + 500 = 1,800 ps.

Where the Human Reference Waits

The human reference keeps the top level in registers. Below it, the counters sit in memory blocks, and in a three-level tree the bottom bitmaps do too. A memory block packs thousands of values into little space. This is what lets BBQ reach 32K priorities on an FPGA [1].

A lower level takes three stages, shown in Figure 3. The first finds the first 1 of the row and asks memory for that bit’s counter. In the second, the counter arrives. The third adds or subtracts one, updates the bit and writes both back.

Deciding whether a bit clears costs little. Each counter carries one extra bit, which the paper calls the waterlevel bit [1]. It says whether the count is at least 2. A removal clears its bit when the waterlevel bit is 0, with no arithmetic on the count.

The wait is in reaching the counter. A memory read lands late in its cycle. By then, an operation just ahead may have changed the same counter. After the read, the level compares the counter with what the operations ahead wrote, and keeps the newest value.

That comparison sets the clock. We timed the human reference with the task’s own script and tools. On the three smallest trees, its slowest stretch starts at the counter memory. It passes three lookup tables: 300 + 1,000 + 3 × 500 = 2,800 ps. On the two largest, the search for the first 1 is slowest, at 3,300 and 3,800 ps.

ONE LOWER LEVEL OF THE HUMAN REFERENCE, THREE STAGES1. Search the rowFind the first 1 of the row.Ask memory for its counter.2. The counter arrivesLate in the cycle. Take the newestvalue, then register it.3. Update and write backAdd or subtract 1. If the waterlevelbit is 0, clear the bit.Stage 2 on the three smallest trees: the slowest stretchcountermemoryLUTLUTLUTcounterregister300 + 1,000 + 3 × 500= 2,800 psThe three lookup tables compare the counter with what theoperations just ahead wrote, and pick the newest value.
Figure 3. One lower level of the human reference. On the three smallest trees, its slowest stretch runs from the counter memory through three lookup tables: 2,800 ps. The three pick the newest value of the counter.

Gemini 4 Argon: Decide Before the Read Lands

Gemini 4 Argon kept every memory of the human reference and the three stages of each lower level. It changed what a level does while the read is in flight, as Figure 4 shows.

Which value is newest does not depend on the value itself. It depends on which operations ahead touched the same counter, and registers hold that. Gemini 4 Argon computes the choice from those registers in parallel with the read. When the counter lands, one lookup table picks it or a newer value. The stretch from memory drops from three lookup tables to one: 1,800 ps.

The search in the first stage has the same problem one stage earlier. It cannot yet know whether the operations ahead clear a bit in the row. Gemini 4 Argon searches three versions of the row at once. One is the row as stored. The other two are the row as the operations one and two ahead would leave it. It keeps the right result once those operations decide.

The top level got a parallel form. Its counters sit in registers, so every bit can read its own waterlevel bit at once. The new top row is the old row with the chosen bit cleared. Every bit whose count is at least 2 is then set back. The top level takes no stage of its own. Each operation needs one cycle fewer: 9 on two levels and 13 on three, against 10 and 14.

On trees of width 4 the clock reaches the floor of 1,800 ps. At widths 8 and 16 it is 2,300 and 2,800 ps. The search for the first 1 and the counter update set it there. The circuit spends about the logic of the human reference. At 4,096 priorities it uses 2,126 lookup tables and 2,295 registers, against 1,694 and 2,431. Every memory stays in use.

GEMINI 4 ARGON: THE SAME THREE STAGES, THE SAME MEMORY1. Search three rowsThe row as stored, and as the oneand two operations ahead leave it.2. The counter arrivesThe choice of value is ready. Onelookup table, then a register.3. Update and write backAs in the human reference.Stage 2: the choice is made from registers while the read is in flightcountermemoryLUTcounterregisterWhich value is newest?from registers, in parallel300 + 1,000 + 1 × 500= 1,800 psThe top level keeps its counters in registers. It clears the chosen bit, then sets back every bitwhose waterlevel bit says the count is at least 2. It takes no stage of its own, so every operationneeds one cycle fewer: 9 on two levels and 13 on three, against 10 and 14.
Figure 4. A lower level as Gemini 4 Argon wrote it. Registers decide during the read which value is newest. The counter then passes one lookup table before a register: 1,800 ps.

Claude Opus 5.5: The Level in Registers

Claude Opus 5.5 removed the wait by removing the memory. Each bucket of a level gets three registers: its bit, its count, and a flag for a count of 1. The flag does the job of the waterlevel bit.

Registers can be read at any moment, so a level needs one stage, not three. In that stage the circuit finds the first 1 of the operation’s row. It updates every row of the level at once. A removal clears a bit when its flag is set, and the new flag says whether the count was 2.

One stage per level has a second effect. An operation leaves a level before the next one enters it. The next operation sees the newest state, so the comparison with the operations ahead disappears.

Claude Opus 5.5 kept this stage short. The stage records which bucket each operation hit, as one flag per bucket. A later stage turns these flags into the digit the next level needs, outside the loop between back-to-back operations.

The clock reaches the floor of 1,800 ps on all four trees of the development feedback. The hidden tests add width 16, which feedback never showed. For a bottom level of more than 1,024 buckets, Claude Opus 5.5 wrote a second form. It keeps the rows in a register file and reads one row per operation. At width 16 the clock is 2,300 ps.

Registers cost space. At 4,096 priorities the circuit uses 26,763 lookup tables and 48,454 registers, against 1,694 and 2,431 for the human reference. The state grows with the number of priorities. The patch handles at most 8,192 priorities, while the paper’s FPGA design holds 32K [1].

CLAUDE OPUS 5.5: EVERY BUCKET IN REGISTERS, ONE STAGE PER LEVELPer bucket, three registersbit0110count is 10010count0210row 0 of Figure 1; the first 1is bucket 1, priority 1One stage, every cycleFind the first 1 of the operation’s row.Update every row of the level at once:a removal clears the bit when its flag says the count is 1,and the new flag says whether the count was 2.The next operation sees the new state one cycle later,so no check for a newer value is needed.Which bucket was hit goes to a later stage, off this loop.Clock: 1,800 ps on every tree of the feedback, 2,300 ps at width 16.A bottom level of more than 1,024 buckets keeps its rows in a register file and reads one row per operation.Trees of more than 8,192 priorities are not built.
Figure 5. A level as Claude Opus 5.5 wrote it: three registers per bucket, and one stage that updates every row. The next operation sees the new state, so no comparison with the operations ahead is needed.

Results

Both circuits answered every operation of all nine workloads correctly. Both beat the human reference on both speeds, on every workload. The chart below shows operations per second at the five tree sizes.

BBQ: operations per second of the two designs
1×1.25×1.5×1.75×2×Operations per second, times the human referenceHuman reference2 levels, width 41.56×, both2 levels, width 81.22×1.56×3 levels, width 41.56×, both3 levels, width 81.44×1.84×3 levels, width 161.36×1.66×1×1.25×1.5×1.75×2×Operations per second, times the human referenceHuman reference2 levels, width 41.56×, both2 levels, width 81.22×1.56×3 levels, width 41.56×, both3 levels, width 81.44×1.84×3 levels, width 161.36×1.66×
Gemini 4 ArgonClaude Opus 5.5
Hidden workloads, each against the human reference in the same run

Claude Opus 5.5 handles 1.56 to 1.84 times the operations per second of the human reference. Gemini 4 Argon handles 1.22 to 1.56 times. On trees of width 4 the two tie, since both reach the floor. The gap opens at widths 8 and 16. The latency of the slowest operation falls by 36 to 53% for Claude Opus 5.5. It falls by 26 to 42% for Gemini 4 Argon. The task scores the runs 42.2 and 37.4, against 26.0 for the human reference.

What each design spends is the other half of the comparison. The chart below counts the logic of each at 4,096 priorities.

BBQ: logic at 4,096 priorities
Lookup tablesHuman reference1,694Gemini 4 Argon2,126Claude Opus 5.526,763RegistersHuman reference2,431Gemini 4 Argon2,295Claude Opus 5.548,454Lookup tablesHuman reference1,694Gemini 4 Argon2,126Claude Opus 5.526,763RegistersHuman reference2,431Gemini 4 Argon2,295Claude Opus 5.548,454
As the task’s synthesis counts them

The task scores speed and correctness, not size. Within those rules, Claude Opus 5.5 bought its extra speed with logic. Gemini 4 Argon found its speed in the order of the work.

The Runs

Claude Opus 5.5 scored 40.9 with its first submission, $7.28 into its run, and 43.3 with its second. Gemini 4 Argon started at 27.7 and reached 38.5 with its second submission. Both final scores sit a little below the best development scores, since the hidden tests add width 16.

Two runs on BBQ: score against cost
01020304050$0$10$20$30$40$50Cost of the run so far in US$Human reference 26.0Gemini 4 Argon, final 37.4Claude Opus 5.5, final 42.201020304050$0$10$20$30$40$50Cost of the run so far in US$Human reference 26.0Gemini 4 Argon, final 37.4Claude Opus 5.5, final 42.2
Gemini 4 ArgonClaude Opus 5.5
Cost as the model gateway or Claude Code reported it

The patches below are the final submissions, the code the hidden workloads scored.

How the Other Models Did

GPT-6.1 Sol passed as well, with 36.7. At width 16 its circuit ran at 3,800 ps, the period of the human reference. It passed there on 1.007 times the operations per second of the human reference. GPT-6 Astra scored 40.4 but failed. It reached 1,800 ps on the four trees of the feedback. At width 16 its clock rose to 4,800 ps.

Muse Spark 1.3, Muse Wonder 1.0 and DeepSeek V4.1 Flash also moved the counters into registers. At width 16 their circuits ran at 5,300 to 8,300 ps, and all three failed. Registers alone did not make a fast clock. The short single stage did.

Kimi K3 kept the memories and ran at 4,300 ps. GLM 5.3, GLM 5.3 Flash, Qwen 3.8 Max and Step 5 Preview gave no correct circuit at width 16.

BBQ: clock period at width 16, by model
01,5003,0004,5006,0007,5009,000Clock period at width 16 in ps, lower is fasterHuman reference 3,800Claude Opus 5.52,300Gemini 4 Argon2,800GPT-6.1 Sol3,800Kimi K34,300GPT-6 Astra4,800Muse Wonder 1.05,300Muse Spark 1.35,800DeepSeek V4.1 Flash8,30003,0006,0009,000Clock period at width 16, psHuman reference 3,800Claude Opus 5.52,300Gemini 4 Argon2,800GPT-6.1 Sol3,800Kimi K34,300GPT-6 Astra4,800Muse Wonder 1.05,300Muse Spark 1.35,800DeepSeek V4.1 Flash8,300
PassesFails
Each model’s run on the hidden workload at width 16

References

  1. Nirav Atre, Hugo Sadok and Justine Sherry. BBQ: A fast and scalable integer priority queue for hardware packet scheduling. In 21st USENIX Symposium on Networked Systems Design and Implementation, NSDI 2024. USENIX.
All posts Back to top

Keep reading