Skip to content

stdatomic integration#22

Draft
gburd wants to merge 8 commits intomasterfrom
stdatomic-integration
Draft

stdatomic integration#22
gburd wants to merge 8 commits intomasterfrom
stdatomic-integration

Conversation

@gburd
Copy link
Copy Markdown
Owner

@gburd gburd commented Mar 31, 2026

No description provided.

gburd added 8 commits March 31, 2026 10:21
  - Hourly upstream sync from postgres/postgres (24x daily)
  - AI-powered PR reviews using AWS Bedrock Claude Sonnet 4.5
  - Multi-platform CI via existing Cirrus CI configuration
  - Cost tracking and comprehensive documentation

  Features:
  - Automatic issue creation on sync conflicts
  - PostgreSQL-specific code review prompts (C, SQL, docs, build)
  - Cost limits: $15/PR, $200/month
  - Inline PR comments with security/performance labels
  - Skip draft PRs to save costs

  Documentation:
  - .github/SETUP_SUMMARY.md - Quick setup overview
  - .github/QUICKSTART.md - 15-minute setup guide
  - .github/PRE_COMMIT_CHECKLIST.md - Verification checklist
  - .github/docs/ - Detailed guides for sync, AI review, Bedrock

  See .github/README.md for complete overview

Complete Phase 3: Windows builds + fix sync for CI/CD commits

Phase 3: Windows Dependency Build System
- Implement full build workflow (OpenSSL, zlib, libxml2)
- Smart caching by version hash (80% cost reduction)
- Dependency bundling with manifest generation
- Weekly auto-refresh + manual triggers
- PowerShell download helper script
- Comprehensive usage documentation

Sync Workflow Fix:
- Allow .github/ commits (CI/CD config) on master
- Detect and reject code commits outside .github/
- Merge upstream while preserving .github/ changes
- Create issues only for actual pristine violations

Documentation:
- Complete Windows build usage guide
- Update all status docs to 100% complete
- Phase 3 completion summary

All three CI/CD phases complete (100%):
✅ Hourly upstream sync with .github/ preservation
✅ AI-powered PR reviews via Bedrock Claude 4.5
✅ Windows dependency builds with smart caching

Cost: $40-60/month total
See .github/PHASE3_COMPLETE.md for details

Fix sync to allow 'dev setup' commits on master

The sync workflow was failing because the 'dev setup v19' commit
modifies files outside .github/. Updated workflows to recognize
commits with messages starting with 'dev setup' as allowed on master.

Changes:
- Detect 'dev setup' commits by message pattern (case-insensitive)
- Allow merge if commits are .github/ OR dev setup OR both
- Update merge messages to reflect preserved changes
- Document pristine master policy with examples

This allows personal development environment commits (IDE configs,
debugging tools, shell aliases, Nix configs, etc.) on master without
violating the pristine mirror policy.

Future dev environment updates should start with 'dev setup' in the
commit message to be automatically recognized and preserved.

See .github/docs/pristine-master-policy.md for complete policy
See .github/DEV_SETUP_FIX.md for fix summary

Optimize CI/CD costs by skipping builds for pristine commits

Add cost optimization to Windows dependency builds to avoid expensive
builds when only pristine commits are pushed (dev setup commits or
.github/ configuration changes).

Changes:
- Add check-changes job to detect pristine-only pushes
- Skip Windows builds when all commits are dev setup or .github/ only
- Add comprehensive cost optimization documentation
- Update README with cost savings (~40% reduction)

Expected savings: ~$3-5/month on Windows builds, ~$40-47/month total
through combined optimizations.

Manual dispatch and scheduled builds always run regardless.
PostgreSQL now requires C11, and MSVC's stdatomic.h support
(introduced in Visual Studio 2022) allows us to use standard
atomics instead of platform-specific implementations.

Update CI configuration to use VS 2022.
Add /experimental:c11atomics flag for MSVC builds to enable
C11 standard atomics support. This is required for MSVC 2022
to use <stdatomic.h>.
* Redirect types and functions to standard C/C++
* Use <atomic> instead for C++11 extensions (as formalized by C++23)
* Add pg_atomic_uint8, pg_atomic_uint16 and pg_atomic(T)
* Provide generic pg_atomic_read(), pg_atomic_write()
* Assume that most basic operations will be called by
  standardized generics in future code, eg atomic_fetch_add()
* Forward all the traditional _32, _64 function names for
  existing code
* Reimplement pg_atomic_flag with pg_atomic(uint8) to allow relaxed load
  (impossible with standard atomic_flag, and pg_atomic(bool) doesn't seem
  to be portable enough)
* Let the compiler/runtime emulate 64 bit atomics with locks for armv7
* The per-compiler headers now just define pg_compiler_barrier_impl()
* The per-arch headers now optionally define
  pg_{memory,read,write}_barrier_impl() but only if they think they can
  do something better than compilers (to investigate...)
* Drop the secondary copy of the ancient spinlock ops from atomics
* Drop arch-{arm,ppc}.h, fallback.h and generic.h

WIP!

TODO: Need to research generated code on all architectures and see if
anything important is lost.
Refactor spinlock implementation to build on top of the new
atomics API instead of duplicating low-level primitives.
Remove obsolete build system checks for atomics since we now
rely on C11 <stdatomic.h> which is guaranteed to be present.
On Windows AArch64 research indicates that ISB performs better than the
YIELD hint instruction at scale.

This matches the pattern used for __aarch64__ with GCC/Clang, which
uses the ISB instruction.

Discussion: https://postgr.es/m/1c2a29b8-5b1e-44f7-a871-71ec5fefc120%40app.fastmail.com
@github-actions github-actions bot force-pushed the master branch 22 times, most recently from e9145b8 to 3ed83ae Compare April 2, 2026 04:44
@github-actions github-actions bot force-pushed the master branch 8 times, most recently from c08b44f to 7c5c2d3 Compare April 2, 2026 22:10
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