Skip to content

Housekeeping: unused dependencies, single-line inputs, own links - #2

Merged
Yarroo merged 9 commits into
masterfrom
standalone-cleanup
Aug 24, 2026
Merged

Housekeeping: unused dependencies, single-line inputs, own links#2
Yarroo merged 9 commits into
masterfrom
standalone-cleanup

Conversation

@Yarroo

@Yarroo Yarroo commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Follow-up to #1, in three groups.

Snapshot correctness and cost

  • fix a race between snapshot rebuild and invalidation — the rebuild assigned @snapshot and then read the ivar back, while reset_snapshot cleared it without the mutex. An after_commit landing between those two lines gave nil.values. The same gap also lost invalidations: a rebuild that started before a commit would finish afterwards and store pre-commit values under a fresh timestamp, so the process that saved a setting served the old value for a whole TTL.
  • serve a stale snapshot while another thread rebuilds it — the rebuild runs a query while holding the mutex, so every other thread in the process used to queue behind it. Now a stale snapshot is served immediately and only one thread rebuilds; a cold start still waits, there is nothing to serve.
  • build the snapshot from an unscoped relationall honours current_scope, so a call made inside relation.scoping would have cached a truncated table for the whole TTL.
  • memoize the settings config instead of re-reading yaml on every callload_config read the file, ran ERB and parsed YAML on every call, and #value asks for all_settings two or three times. Building a snapshot of a thousand settings meant thousands of parses, under the mutex. reload_config! clears both.

Rails compatibility

  • replace render :text and update_attributes — removed in Rails 5.1 and 6 respectively; AdminUsersController could not work at all on a current Rails.
  • keep plain settings on a single-line input — the migration already creates t.text :string so long values are not truncated, which makes formtastic infer a textarea for every plain setting. This is the other half of Fix long strings, prevent 255 char truncation slate-studio/activeadmin-settings#25.

Housekeeping for a standalone repository

  • drop unused runtime dependencies — the uploaders went away in f8146e0 and carrierwave, mini_magick and devise are not referenced anywhere since. Version goes to 0.6.0.
  • drop mongoid instructions — the model is ActiveRecord::Base; those sections only kept the removed dependencies alive in the docs.
  • point homepage and readme images at this repository. Authorship left as it was.

Verified on a live Rails app: 60 reads from a cold snapshot cost 1 query and the next 60 cost none; with the mutex held elsewhere a read of a stale snapshot returns in 0.1 ms instead of blocking; 3200 reads across 8 threads alongside 60 writes raise nothing; a value read after a write is fresh.

@Yarroo
Yarroo force-pushed the standalone-cleanup branch from 281ff7f to 609c5d8 Compare August 24, 2026 13:18
@Yarroo
Yarroo merged commit 59f3d69 into master Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant