Repository navigation
Run lobsters with a fixed clock next to its fixture - #572
Open
thomasklemm wants to merge 1 commit into
Open
thomasklemm wants to merge 1 commit into
thomasklemm wants to merge 1 commit into
Conversation
thomasklemm
force-pushed
the
thomasklemm/lobsters-clock-near-fixture
branch
from
November 5, 2026 20:25
1486f3e to
aea1904
Compare
The fixture's stories are from 2023-07-18, so with the real clock /active, /recent and /top render empty lists. Time.now now returns 2023-07-19 01:00 UTC, which also keeps the work from changing with the date (DST changes in the app's US Central time zone, a holiday logo). Harness code outside the benchmark block keeps the real clock. TRACK_AR_TIME measures with the monotonic clock.
StoryRepository#top asked SQLite for DATETIME('now', '- 1 DAY'), which is NULL ('- 1' isn't a valid modifier, and SQLite has no WEEK), so /top was always empty. It now passes Time.current and converts weeks to days, as upstream lobsters' IntervalHelper does.
thomasklemm
force-pushed
the
thomasklemm/lobsters-clock-near-fixture
branch
from
November 5, 2026 20:32
aea1904 to
f94d3a1
Compare
thomasklemm
marked this pull request as ready for review
November 5, 2026 21:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Alternative to #571: also fixes the clock, but near the fixture's dates, so the 16 time-filtered requests render stories. Merge one of the two.
The fixture's stories are from 2023-07-18, so on main /active, /recent and /top?length=1d|1w|1y (16 of 114 requests per iteration) render empty lists. This fixes
Time.nowat 2023-07-19 01:00 UTC, about 15 hours after the stories, during boot and in the benchmark block. Across the four tested dates (2026-11-05, 2026-12-25, 2027-03-20, 2027-06-28), allocations per iteration varied by 0.003%, against 1.37% on main./top never listed a story on main:
DATETIME('now', '- 1 DAY')is NULL, because SQLite rejects- 1and has no WEEK. The modifier is now-1 DAY, with weeks as 7 days, as in upstream lobsters. The deliberate departure from upstream is that the query bindsTime.currentinstead of SQLite's'now', so /top follows the fixed clock.Per pass after one warmup pass, Ruby 4.0.9:
The 16 requests render 25 stories each. Since stories and comments are hours old, pages also take the branches for recent content: reply and flag links, delete instead of disown, comment scores under 36 hours shown as
~, one user marked as new. This is a deliberate workload change of about +44% objects per iteration against main (+46% against #571).Response bodies are byte-identical between runs on 2026-11-05 and 2027-01-20, apart from CSRF tokens. The harness keeps the real clock.
Date.today,DateTime.nowandTime.newwithout arguments stay live. Cache entries and the session no longer age.TRACK_AR_TIMEuses the monotonic clock.How this was measured
Per pass: route_dump.rb records status, bytes,
<li id="story_count and allocated objects of each request in the pass after one warmup pass; route_table.rb sums them. Date spread:GC.stat(:total_allocated_objects)around each iteration of the default harness,WARMUP_ITRS=1 MIN_BENCH_ITRS=3, mean of the 3 measured iterations per date, spread = (max − min) / min of the per-date means, system clock set with libfaketime (FAKETIME='@<date> 12:00:00' FAKETIME_DONT_FAKE_MONOTONIC=1), cg_harness.rb withCG_DUMP=0. Responses: raw_dump.rb writes status, headers and body of all 114 requests in the pass after one warmup pass; raw_cmp.rb blanks theauthenticity_tokenvalues, thecsrf-tokenmeta tag and the random headers (session cookie, ETag, X-Request-Id, X-Runtime) and compares the rest byte for byte: 0 of 114 differ.