AWS: PostgreSQL on Graviton2 with newer GCC
Tags: aws, postgres, graviton2, gcc
Published: 2021-05-15 04:55:09

In the <a href="https://dev.to/aws-heroes/aws-postgresql-on-graviton2-3n44" rel="noopener" target="_blank">previous post</a> I have run PostgreSQL on AWS m6gd.2xlarge (ARM Graviton2 processor).
I didn't precise the compilation option and this post will give more details following this feedback: 
https://twitter.com/N_B__N_B/status/1369180884608315398

First, the PostgreSQL ./configure has correctly detected ARM and compiled with the following flags: -march=armv8-a+crc 
This is ARM v8. However, LSE (Large System Extensions) for atomic instructions were added later in ARM v8.1 and they can make a huge difference on PostgreSQL especially with spinlocks on on high CPU usage.

I followed the information in <a href="https://github.com/aws/aws-graviton-getting-started/blob/master/c-c++.md" rel="noopener" target="_blank">https://github.com/aws/aws-graviton-getting-started/blob/master/c-c++.md</a> to check the binaries after compilation.

<pre><code>
for i in $(find postgres/src/backend -name "*.o") ; do objdump -d "$i" | awk '/:$/{w=$2}/aarch64_(cas|casp|swp|ldadd|stadd|ldclr|stclr|ldeor|steor|ldset|stset|ldsmax|stsmax|ldsmin|stsmin|ldumax|stumax|ldumin|stumin)/{printf "%-27s %-20s %-30s %-60s\n","(LSE instructions)",$NF,w,f}' f="$i" ; done | sort | uniq -c | sort -rnk1,4


      8 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;StartupXLOG&gt;:                 postgres/src/backend/access/transam/xlog.o
      7 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;BitmapHeapNext&gt;:              postgres/src/backend/executor/nodeBitmapHeapscan.o
      6 (LSE instructions)          &lt;__aarch64_ldclr4_acq_rel&gt; &lt;LWLockDequeueSelf&gt;:           postgres/src/backend/storage/lmgr/lwlock.o
      6 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;shm_mq_send_bytes&gt;:           postgres/src/backend/storage/ipc/shm_mq.o
      5 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;WalReceiverMain&gt;:             postgres/src/backend/replication/walreceiver.o
      5 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;shm_mq_receive_bytes.isra.0&gt;: postgres/src/backend/storage/ipc/shm_mq.o
      4 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ProcessRepliesIfAny&gt;:         postgres/src/backend/replication/walsender.o
      4 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;hash_search_with_hash_value&gt;: postgres/src/backend/utils/hash/dynahash.o
      4 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;copy_replication_slot&gt;:       postgres/src/backend/replication/slotfuncs.o
      4 (LSE instructions)          &lt;__aarch64_ldadd4_acq_rel&gt; &lt;parallel_vacuum_index&gt;:       postgres/src/backend/access/heap/vacuumlazy.o
      4 (LSE instructions)          &lt;__aarch64_cas4_acq_rel&gt; &lt;LWLockAcquire&gt;:               postgres/src/backend/storage/lmgr/lwlock.o
      3 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;xlog_redo&gt;:                   postgres/src/backend/access/transam/xlog.o
      3 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;XLogInsertRecord&gt;:            postgres/src/backend/access/transam/xlog.o
      3 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;SaveSlotToPath&gt;:              postgres/src/backend/replication/slot.o
      3 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;RequestCheckpoint&gt;:           postgres/src/backend/postmaster/checkpointer.o
      3 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;LogicalRepSyncTableStart&gt;:    postgres/src/backend/replication/logical/tablesync.o
      3 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;LogicalConfirmReceivedLocation&gt;: postgres/src/backend/replication/logical/logical.o
      3 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;InvalidateObsoleteReplicationSlots&gt;: postgres/src/backend/replication/slot.o
      3 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;CreateInitDecodingContext&gt;:   postgres/src/backend/replication/logical/logical.o
      3 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;CreateCheckPoint&gt;:            postgres/src/backend/access/transam/xlog.o
      3 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;CheckpointerMain&gt;:            postgres/src/backend/postmaster/checkpointer.o
      3 (LSE instructions)          &lt;__aarch64_ldclr4_acq_rel&gt; &lt;LWLockQueueSelf&gt;:             postgres/src/backend/storage/lmgr/lwlock.o
      3 (LSE instructions)          &lt;__aarch64_ldadd4_acq_rel&gt; &lt;tbm_prepare_shared_iterate&gt;:  postgres/src/backend/nodes/tidbitmap.o
      3 (LSE instructions)          &lt;__aarch64_ldadd4_acq_rel&gt; &lt;tbm_free_shared_area&gt;:        postgres/src/backend/nodes/tidbitmap.o
      3 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;ProcessProcSignalBarrier&gt;:    postgres/src/backend/storage/ipc/procsignal.o
      3 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;ExecParallelHashIncreaseNumBatches&gt;: postgres/src/backend/executor/nodeHash.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;XLogWrite&gt;:                   postgres/src/backend/access/transam/xlog.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;XLogSendPhysical&gt;:            postgres/src/backend/replication/walsender.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;XLogBackgroundFlush&gt;:         postgres/src/backend/access/transam/xlog.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;WalRcvStreaming&gt;:             postgres/src/backend/replication/walreceiverfuncs.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;WalRcvRunning&gt;:               postgres/src/backend/replication/walreceiverfuncs.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;WalRcvDie&gt;:                   postgres/src/backend/replication/walreceiver.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;TransactionIdLimitedForOldSnapshots&gt;: postgres/src/backend/utils/time/snapmgr.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;StrategyGetBuffer&gt;:           postgres/src/backend/storage/buffer/freelist.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;shm_mq_wait_internal&gt;:        postgres/src/backend/storage/ipc/shm_mq.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ReplicationSlotReserveWal&gt;:   postgres/src/backend/replication/slot.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ReplicationSlotRelease&gt;:      postgres/src/backend/replication/slot.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ProcKill&gt;:                    postgres/src/backend/storage/lmgr/proc.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;process_syncing_tables&gt;:      postgres/src/backend/replication/logical/tablesync.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;pg_get_replication_slots&gt;:    postgres/src/backend/replication/slotfuncs.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;exec_replication_command&gt;:    postgres/src/backend/replication/walsender.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;CreateRestartPoint&gt;:          postgres/src/backend/access/transam/xlog.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ConditionVariableBroadcast&gt;:  postgres/src/backend/storage/lmgr/condition_variable.o
      2 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;BarrierArriveAndWait&gt;:        postgres/src/backend/storage/ipc/barrier.o
      2 (LSE instructions)          &lt;__aarch64_ldset4_acq_rel&gt; &lt;LWLockWaitListLock&gt;:          postgres/src/backend/storage/lmgr/lwlock.o
      2 (LSE instructions)          &lt;__aarch64_ldclr4_acq_rel&gt; &lt;LWLockWaitForVar&gt;:            postgres/src/backend/storage/lmgr/lwlock.o
      2 (LSE instructions)          &lt;__aarch64_ldclr4_acq_rel&gt; &lt;LWLockUpdateVar&gt;:             postgres/src/backend/storage/lmgr/lwlock.o
      2 (LSE instructions)          &lt;__aarch64_ldadd4_acq_rel&gt; &lt;vacuum_delay_point&gt;:          postgres/src/backend/commands/vacuum.o
      2 (LSE instructions)          &lt;__aarch64_ldadd4_acq_rel&gt; &lt;StrategyGetBuffer&gt;:           postgres/src/backend/storage/buffer/freelist.o
      2 (LSE instructions)          &lt;__aarch64_ldadd4_acq_rel&gt; &lt;LWLockRelease&gt;:               postgres/src/backend/storage/lmgr/lwlock.o
      2 (LSE instructions)          &lt;__aarch64_ldadd4_acq_rel&gt; &lt;lazy_parallel_vacuum_indexes&gt;: postgres/src/backend/access/heap/vacuumlazy.o
      2 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;WalReceiverMain&gt;:             postgres/src/backend/replication/walreceiver.o
      2 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;WaitForProcSignalBarrier&gt;:    postgres/src/backend/storage/ipc/procsignal.o
      2 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;shm_mq_receive&gt;:              postgres/src/backend/storage/ipc/shm_mq.o
      2 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;ResolveRecoveryConflictWithLock&gt;: postgres/src/backend/storage/ipc/standby.o
      2 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;ProcSignalInit&gt;:              postgres/src/backend/storage/ipc/procsignal.o
      2 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;ExecParallelHashTableInsert&gt;: postgres/src/backend/executor/nodeHash.o
      2 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;ExecParallelHashTableInsertCurrentBatch&gt;: postgres/src/backend/executor/nodeHash.o
      2 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;ExecParallelHashIncreaseNumBuckets&gt;: postgres/src/backend/executor/nodeHash.o
      2 (LSE instructions)          &lt;__aarch64_cas4_acq_rel&gt; &lt;TransactionIdSetTreeStatus&gt;:  postgres/src/backend/access/transam/clog.o
      2 (LSE instructions)          &lt;__aarch64_cas4_acq_rel&gt; &lt;ProcArrayEndTransaction&gt;:     postgres/src/backend/storage/ipc/procarray.o
      2 (LSE instructions)          &lt;__aarch64_cas4_acq_rel&gt; &lt;LWLockAcquireOrWait&gt;:         postgres/src/backend/storage/lmgr/lwlock.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;XLogWalRcvFlush.part.4&gt;:      postgres/src/backend/replication/walreceiver.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;XLogSetReplicationSlotMinimumLSN&gt;: postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;XLogSetAsyncXactLSN&gt;:         postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;XLogSendLogical&gt;:             postgres/src/backend/replication/walsender.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;XLogPageRead&gt;:                postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;XLogNeedsFlush&gt;:              postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;XLogGetLastRemovedSegno&gt;:     postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;XLogFlush&gt;:                   postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;worker_freeze_result_tape&gt;:   postgres/src/backend/utils/sort/tuplesort.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;WalSndWakeup&gt;:                postgres/src/backend/replication/walsender.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;WalSndWaitStopping&gt;:          postgres/src/backend/replication/walsender.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;WalSndSetState&gt;:              postgres/src/backend/replication/walsender.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;WalSndRqstFileReload&gt;:        postgres/src/backend/replication/walsender.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;WalSndKill&gt;:                  postgres/src/backend/replication/walsender.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;WalSndInitStopping&gt;:          postgres/src/backend/replication/walsender.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;WalRcvForceReply&gt;:            postgres/src/backend/replication/walreceiver.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;WaitXLogInsertionsToFinish&gt;:  postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;UpdateMinRecoveryPoint.part.10&gt;: postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;tuplesort_performsort&gt;:       postgres/src/backend/utils/sort/tuplesort.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;tuplesort_begin_common&gt;:      postgres/src/backend/utils/sort/tuplesort.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;table_block_parallelscan_startblock_init&gt;: postgres/src/backend/access/table/tableam.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;SyncRepInitConfig&gt;:           postgres/src/backend/replication/syncrep.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;SyncRepGetCandidateStandbys&gt;: postgres/src/backend/replication/syncrep.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;StrategySyncStart&gt;:           postgres/src/backend/storage/buffer/freelist.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;StrategyNotifyBgWriter&gt;:      postgres/src/backend/storage/buffer/freelist.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;StrategyFreeBuffer&gt;:          postgres/src/backend/storage/buffer/freelist.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;SnapshotTooOldMagicForTest&gt;:  postgres/src/backend/utils/time/snapmgr.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;s_lock&gt;:                      postgres/src/backend/storage/lmgr/s_lock.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;SIInsertDataEntries&gt;:         postgres/src/backend/storage/ipc/sinvaladt.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;SIGetDataEntries&gt;:            postgres/src/backend/storage/ipc/sinvaladt.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ShutdownWalRcv&gt;:              postgres/src/backend/replication/walreceiverfuncs.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;shm_toc_insert&gt;:              postgres/src/backend/storage/ipc/shm_toc.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;shm_toc_freespace&gt;:           postgres/src/backend/storage/ipc/shm_toc.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;shm_toc_allocate&gt;:            postgres/src/backend/storage/ipc/shm_toc.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;shm_mq_set_sender&gt;:           postgres/src/backend/storage/ipc/shm_mq.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;shm_mq_set_receiver&gt;:         postgres/src/backend/storage/ipc/shm_mq.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;shm_mq_sendv&gt;:                postgres/src/backend/storage/ipc/shm_mq.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;shm_mq_get_sender&gt;:           postgres/src/backend/storage/ipc/shm_mq.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;shm_mq_get_receiver&gt;:         postgres/src/backend/storage/ipc/shm_mq.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;shm_mq_detach_internal&gt;:      postgres/src/backend/storage/ipc/shm_mq.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ShmemAllocRaw&gt;:               postgres/src/backend/storage/ipc/shmem.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;SharedFileSetOnDetach&gt;:       postgres/src/backend/storage/file/sharedfileset.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;SharedFileSetAttach&gt;:         postgres/src/backend/storage/file/sharedfileset.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;SetWalWriterSleeping&gt;:        postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;SetRecoveryPause&gt;:            postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;SetPromoteIsTriggered&gt;:       postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;SetOldSnapshotThresholdTimestamp&gt;: postgres/src/backend/utils/time/snapmgr.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;RequestXLogStreaming&gt;:        postgres/src/backend/replication/walreceiverfuncs.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ReplicationSlotsDropDBSlots&gt;: postgres/src/backend/replication/slot.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ReplicationSlotsCountDBSlots&gt;: postgres/src/backend/replication/slot.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ReplicationSlotsComputeRequiredXmin&gt;: postgres/src/backend/replication/slot.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ReplicationSlotsComputeRequiredLSN&gt;: postgres/src/backend/replication/slot.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ReplicationSlotsComputeLogicalRestartLSN&gt;: postgres/src/backend/replication/slot.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ReplicationSlotPersist&gt;:      postgres/src/backend/replication/slot.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ReplicationSlotMarkDirty&gt;:    postgres/src/backend/replication/slot.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ReplicationSlotDropPtr&gt;:      postgres/src/backend/replication/slot.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ReplicationSlotCreate&gt;:       postgres/src/backend/replication/slot.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ReplicationSlotCleanup&gt;:      postgres/src/backend/replication/slot.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ReplicationSlotAcquireInternal&gt;: postgres/src/backend/replication/slot.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;RemoveOldXlogFiles&gt;:          postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;RemoveLocalLock&gt;:             postgres/src/backend/storage/lmgr/lock.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;RecoveryRestartPoint&gt;:        postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;RecoveryIsPaused&gt;:            postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ReadRecord&gt;:                  postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;PublishStartupProcessInformation&gt;: postgres/src/backend/storage/lmgr/proc.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;PromoteIsTriggered&gt;:          postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ProcSendSignal&gt;:              postgres/src/backend/storage/lmgr/proc.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ProcessWalSndrMessage&gt;:       postgres/src/backend/replication/walreceiver.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;PhysicalReplicationSlotNewXmin&gt;: postgres/src/backend/replication/walsender.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;pg_stat_get_wal_senders&gt;:     postgres/src/backend/replication/walsender.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;pg_stat_get_wal_receiver&gt;:    postgres/src/backend/replication/walreceiver.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;pg_replication_slot_advance&gt;: postgres/src/backend/replication/slotfuncs.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ParallelWorkerReportLastRecEnd&gt;: postgres/src/backend/access/transam/parallel.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;MaintainOldSnapshotTimeMapping&gt;: postgres/src/backend/utils/time/snapmgr.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;LWLockNewTrancheId&gt;:          postgres/src/backend/storage/lmgr/lwlock.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;LogicalIncreaseXminForSlot&gt;:  postgres/src/backend/replication/logical/logical.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;LogicalIncreaseRestartDecodingForSlot&gt;: postgres/src/backend/replication/logical/logical.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;lock_twophase_recover&gt;:       postgres/src/backend/storage/lmgr/lock.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;LockRefindAndRelease&gt;:        postgres/src/backend/storage/lmgr/lock.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;LockAcquireExtended&gt;:         postgres/src/backend/storage/lmgr/lock.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;KnownAssignedXidsSearch&gt;:     postgres/src/backend/storage/ipc/procarray.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;KnownAssignedXidsGetAndSetXmin&gt;: postgres/src/backend/storage/ipc/procarray.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;KnownAssignedXidsAdd&gt;:        postgres/src/backend/storage/ipc/procarray.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;KeepLogSeg&gt;:                  postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;InitWalSender&gt;:               postgres/src/backend/replication/walsender.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;InitProcess&gt;:                 postgres/src/backend/storage/lmgr/proc.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;InitAuxiliaryProcess&gt;:        postgres/src/backend/storage/lmgr/proc.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;HotStandbyActive&gt;:            postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;HaveNFreeProcs&gt;:              postgres/src/backend/storage/lmgr/proc.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;GetXLogWriteRecPtr&gt;:          postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;GetXLogReplayRecPtr&gt;:         postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;GetXLogInsertRecPtr&gt;:         postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;GetWalRcvFlushRecPtr&gt;:        postgres/src/backend/replication/walreceiverfuncs.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;GetSnapshotCurrentTimestamp&gt;: postgres/src/backend/utils/time/snapmgr.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;GetReplicationTransferLatency&gt;: postgres/src/backend/replication/walreceiverfuncs.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;GetReplicationApplyDelay&gt;:    postgres/src/backend/replication/walreceiverfuncs.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;GetRedoRecPtr&gt;:               postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;GetRecoveryState&gt;:            postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;GetOldSnapshotThresholdTimestamp&gt;: postgres/src/backend/utils/time/snapmgr.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;GetLatestXTime&gt;:              postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;GetInsertRecPtr&gt;:             postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;GetFlushRecPtr&gt;:              postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;GetFakeLSNForUnloggedRel&gt;:    postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;GetCurrentChunkReplayStartTime&gt;: postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;FirstCallSinceLastCheckpoint&gt;: postgres/src/backend/postmaster/checkpointer.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;element_alloc&gt;:               postgres/src/backend/utils/hash/dynahash.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;do_pg_stop_backup&gt;:           postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;do_pg_start_backup&gt;:          postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;DecodingContextFindStartpoint&gt;: postgres/src/backend/replication/logical/logical.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ConditionVariableTimedSleep&gt;: postgres/src/backend/storage/lmgr/condition_variable.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ConditionVariableSignal&gt;:     postgres/src/backend/storage/lmgr/condition_variable.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ConditionVariablePrepareToSleep&gt;: postgres/src/backend/storage/lmgr/condition_variable.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ConditionVariableCancelSleep&gt;: postgres/src/backend/storage/lmgr/condition_variable.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;ComputeXidHorizons&gt;:          postgres/src/backend/storage/ipc/procarray.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;CheckXLogRemoved&gt;:            postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;CheckRecoveryConsistency.part.11&gt;: postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;_bt_parallel_seize&gt;:          postgres/src/backend/access/nbtree/nbtree.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;_bt_parallel_scan_and_sort&gt;:  postgres/src/backend/access/nbtree/nbtsort.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;btparallelrescan&gt;:            postgres/src/backend/access/nbtree/nbtree.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;_bt_parallel_release&gt;:        postgres/src/backend/access/nbtree/nbtree.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;_bt_parallel_done&gt;:           postgres/src/backend/access/nbtree/nbtree.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;_bt_parallel_advance_array_keys&gt;: postgres/src/backend/access/nbtree/nbtree.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;btbuild&gt;:                     postgres/src/backend/access/nbtree/nbtsort.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;BarrierParticipants&gt;:         postgres/src/backend/storage/ipc/barrier.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;BarrierDetach&gt;:               postgres/src/backend/storage/ipc/barrier.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;BarrierAttach&gt;:               postgres/src/backend/storage/ipc/barrier.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;BarrierArriveAndDetach&gt;:      postgres/src/backend/storage/ipc/barrier.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;BarrierArriveAndDetachExceptLast&gt;: postgres/src/backend/storage/ipc/barrier.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;AuxiliaryProcKill&gt;:           postgres/src/backend/storage/lmgr/proc.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;AdvanceXLInsertBuffer&gt;:       postgres/src/backend/access/transam/xlog.o
      1 (LSE instructions)          &lt;__aarch64_swp4_acq&gt; &lt;AbortStrongLockAcquire&gt;:      postgres/src/backend/storage/lmgr/lock.o
      1 (LSE instructions)          &lt;__aarch64_ldset4_acq_rel&gt; &lt;ProcessProcSignalBarrier&gt;:    postgres/src/backend/storage/ipc/procsignal.o
      1 (LSE instructions)          &lt;__aarch64_ldset4_acq_rel&gt; &lt;LWLockWaitForVar&gt;:            postgres/src/backend/storage/lmgr/lwlock.o
      1 (LSE instructions)          &lt;__aarch64_ldset4_acq_rel&gt; &lt;LWLockQueueSelf&gt;:             postgres/src/backend/storage/lmgr/lwlock.o
      1 (LSE instructions)          &lt;__aarch64_ldset4_acq_rel&gt; &lt;LWLockDequeueSelf&gt;:           postgres/src/backend/storage/lmgr/lwlock.o
      1 (LSE instructions)          &lt;__aarch64_ldset4_acq_rel&gt; &lt;LWLockAcquire&gt;:               postgres/src/backend/storage/lmgr/lwlock.o
      1 (LSE instructions)          &lt;__aarch64_ldset4_acq_rel&gt; &lt;LockBufHdr&gt;:                  postgres/src/backend/storage/buffer/bufmgr.o
      1 (LSE instructions)          &lt;__aarch64_ldset4_acq_rel&gt; &lt;EmitProcSignalBarrier&gt;:       postgres/src/backend/storage/ipc/procsignal.o
      1 (LSE instructions)          &lt;__aarch64_ldclr4_acq_rel&gt; &lt;LWLockReleaseClearVar&gt;:       postgres/src/backend/storage/lmgr/lwlock.o
      1 (LSE instructions)          &lt;__aarch64_ldadd8_acq_rel&gt; &lt;table_block_parallelscan_nextpage&gt;: postgres/src/backend/access/table/tableam.o
      1 (LSE instructions)          &lt;__aarch64_ldadd8_acq_rel&gt; &lt;EmitProcSignalBarrier&gt;:       postgres/src/backend/storage/ipc/procsignal.o
      1 (LSE instructions)          &lt;__aarch64_ldadd4_acq_rel&gt; &lt;find_or_make_matching_shared_tupledesc&gt;: postgres/src/backend/utils/cache/typcache.o
      1 (LSE instructions)          &lt;__aarch64_ldadd4_acq_rel&gt; &lt;ExecParallelHashJoin&gt;:        postgres/src/backend/executor/nodeHashjoin.o
      1 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;table_block_parallelscan_reinitialize&gt;: postgres/src/backend/access/table/tableam.o
      1 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;ProcWakeup&gt;:                  postgres/src/backend/storage/lmgr/proc.o
      1 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;ProcSleep&gt;:                   postgres/src/backend/storage/lmgr/proc.o
      1 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;pg_stat_get_wal_receiver&gt;:    postgres/src/backend/replication/walreceiver.o
      1 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;InitProcess&gt;:                 postgres/src/backend/storage/lmgr/proc.o
      1 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;InitAuxiliaryProcess&gt;:        postgres/src/backend/storage/lmgr/proc.o
      1 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;GetWalRcvWriteRecPtr&gt;:        postgres/src/backend/replication/walreceiverfuncs.o
      1 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;GetLockStatusData&gt;:           postgres/src/backend/storage/lmgr/lock.o
      1 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;ExecParallelScanHashBucket&gt;:  postgres/src/backend/executor/nodeHash.o
      1 (LSE instructions)          &lt;__aarch64_cas8_acq_rel&gt; &lt;CleanupProcSignalState&gt;:      postgres/src/backend/storage/ipc/procsignal.o
      1 (LSE instructions)          &lt;__aarch64_cas4_acq_rel&gt; &lt;UnpinBuffer.constprop.11&gt;:    postgres/src/backend/storage/buffer/bufmgr.o
      1 (LSE instructions)          &lt;__aarch64_cas4_acq_rel&gt; &lt;StrategySyncStart&gt;:           postgres/src/backend/storage/buffer/freelist.o
      1 (LSE instructions)          &lt;__aarch64_cas4_acq_rel&gt; &lt;StrategyGetBuffer&gt;:           postgres/src/backend/storage/buffer/freelist.o
      1 (LSE instructions)          &lt;__aarch64_cas4_acq_rel&gt; &lt;ProcessProcSignalBarrier&gt;:    postgres/src/backend/storage/ipc/procsignal.o
      1 (LSE instructions)          &lt;__aarch64_cas4_acq_rel&gt; &lt;PinBuffer&gt;:                   postgres/src/backend/storage/buffer/bufmgr.o
      1 (LSE instructions)          &lt;__aarch64_cas4_acq_rel&gt; &lt;MarkBufferDirty&gt;:             postgres/src/backend/storage/buffer/bufmgr.o
      1 (LSE instructions)          &lt;__aarch64_cas4_acq_rel&gt; &lt;LWLockRelease&gt;:               postgres/src/backend/storage/lmgr/lwlock.o
      1 (LSE instructions)          &lt;__aarch64_cas4_acq_rel&gt; &lt;LWLockConditionalAcquire&gt;:    postgres/src/backend/storage/lmgr/lwlock.o
</code></pre>
So, this confirms that it was compiled with -march=armv8-a and outline -moutline-atomics (which is the default in GCC &gt;= 10 and also in the GCC 7 compiled in Amazon Linux 2). LSE (Large-System Extensions) are there, and we can see where the atomic instructions are used: WAL and buffer lightweight locks that protect access to shared memory.

<pre><code>for i in /usr/local/pgsql/bin/postgres $(find postgres/src/backend -name "*.o") ; do objdump -d "$i" | awk '/:$/{w=$2}/aarch64_(cas|casp|swp|ldadd|stadd|ldclr|stclr|ldeor|steor|ldset|stset|ldsmax|stsmax|ldsmin|stsmin|ldumax|stumax|ldumin|stumin)/{printf "%-27s %-40s %-40s %-60s\n","(LSE instructions)",$NF,w,f}/\t(ldxr|ldaxr|stxr|stlxr)\t/{printf "%-27s %-40s %-40s %-60s\n","(load and store exclusives)",$3,w,f}' f="$i" ; done | sort | uniq -c | sort -rn

      1 (load and store exclusives) stxr                                     &lt;__aarch64_swp4_acq&gt;:                    /usr/local/pgsql/bin/postgres
      1 (load and store exclusives) stlxr                                    &lt;__aarch64_ldset4_acq_rel&gt;:              /usr/local/pgsql/bin/postgres
      1 (load and store exclusives) stlxr                                    &lt;__aarch64_ldclr4_acq_rel&gt;:              /usr/local/pgsql/bin/postgres
      1 (load and store exclusives) stlxr                                    &lt;__aarch64_ldadd8_acq_rel&gt;:              /usr/local/pgsql/bin/postgres
      1 (load and store exclusives) stlxr                                    &lt;__aarch64_ldadd4_acq_rel&gt;:              /usr/local/pgsql/bin/postgres
      1 (load and store exclusives) stlxr                                    &lt;__aarch64_cas8_acq_rel&gt;:                /usr/local/pgsql/bin/postgres
      1 (load and store exclusives) stlxr                                    &lt;__aarch64_cas4_acq_rel&gt;:                /usr/local/pgsql/bin/postgres
      1 (load and store exclusives) ldaxr                                    &lt;__aarch64_swp4_acq&gt;:                    /usr/local/pgsql/bin/postgres
      1 (load and store exclusives) ldaxr                                    &lt;__aarch64_ldset4_acq_rel&gt;:              /usr/local/pgsql/bin/postgres
      1 (load and store exclusives) ldaxr                                    &lt;__aarch64_ldclr4_acq_rel&gt;:              /usr/local/pgsql/bin/postgres
      1 (load and store exclusives) ldaxr                                    &lt;__aarch64_ldadd8_acq_rel&gt;:              /usr/local/pgsql/bin/postgres
      1 (load and store exclusives) ldaxr                                    &lt;__aarch64_ldadd4_acq_rel&gt;:              /usr/local/pgsql/bin/postgres
      1 (load and store exclusives) ldaxr                                    &lt;__aarch64_cas8_acq_rel&gt;:                /usr/local/pgsql/bin/postgres
      1 (load and store exclusives) ldaxr                                    &lt;__aarch64_cas4_acq_rel&gt;:                /usr/local/pgsql/bin/postgres
</code></pre>
This confirms that the PostgreSQL binary also contains load and store exclusives so that the binary can run on Graviton and Graviton2.

<pre><code>
[ec2-user@ip-172-31-11-116 ~]$ nm /usr/local/pgsql/bin/postgres | grep -E "aarch64(_have_lse_atomics)?"

00000000008fb460 t __aarch64_cas4_acq_rel
00000000008fb490 t __aarch64_cas8_acq_rel
0000000000bbe640 b __aarch64_have_lse_atomics
00000000008fb4f0 t __aarch64_ldadd4_acq_rel
00000000008fb580 t __aarch64_ldadd8_acq_rel
00000000008fb520 t __aarch64_ldclr4_acq_rel
00000000008fb550 t __aarch64_ldset4_acq_rel
00000000008fb4c0 t __aarch64_swp4_acq
</code></pre>
This is the run-time detection. As it was compiled for ARM v8, with atomics outlined, the same binary can run on v8 or &gt;=v8.1

<pre><code>
[ec2-user@ip-172-31-11-116 ~]$ gcc --version
gcc (GCC) 7.3.1 20180712 (Red Hat 7.3.1-12)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
</code></pre>
This is GCC 7, but on Amazon Linux 2 it has been patched to enable -moutline-atomics by default.

<h3>Install latest version of GCC (version 11 experimental)</h3>

Here is how I compiled the latest GCC available:
<pre><code>
gcc --version
sudo yum -y install bzip2 git gcc gcc-c++ gmp-devel mpfr-devel libmpc-devel make flex bison
git clone https://github.com/gcc-mirror/gcc.git
cd gcc
make distclean
./configure --enable-languages=c,c++
make
sudo make install
</code></pre>
This basically get the latest GCC fron source, compiles and installs it (please remember this is a lab - use stable versions elswhere)

<pre><code>[ec2-user@ip-172-31-38-254 ~]$ gcc --version
gcc (GCC) 11.0.1 20210309 (experimental)
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</code></pre>
Here we are: gcc 11.0.1 20210309 (experimental)

<h3>PGIO LIOPS</h3>

I'm running the same PGIO as in previous post

<pre><code>
Date: Wed Mar 10 14:39:38 UTC 2021
Database connect string: "pgio".
Shared buffers: 8500MB.
Testing 4 schemas with 1 thread(s) accessing 1024M (131072 blocks) of each schema.
Running iostat, vmstat and mpstat on current host--in background.
Launching sessions. 4 schema(s) will be accessed by 1 thread(s) each.
pg_stat_database stats:
          datname| blks_hit| blks_read|tup_returned|tup_fetched|tup_updated
BEFORE:  pgio    | 38262338086 |    562443 |  37644815538 | 37635763756 |          24
AFTER:   pgio    | 49691750429 |    562449 |  48890461241 | 48878858651 |          49
DBNAME:  pgio. 4 schemas, 1 threads(each). Run time: 3600 seconds. RIOPS &gt;793709&lt;
</code></pre>
This is a little higher than what I had: 793709 LIOPS / CPU where I had 780651 with GCC 7 but that's still lower than the 896280 I had on x86.

Of course, there can be more optimisations as mentioned in <a href="https://github.com/aws/aws-graviton-getting-started/blob/master/c-c++.md" rel="noopener" target="_blank">https://github.com/aws/aws-graviton-getting-started/blob/master/c-c++.md</a>
I'll recompile with the recommended flags

<pre><code>(
cd postgres
CFLAGS="-march=armv8.2-a+fp16+rcpc+dotprod+crypto -mtune=neoverse-n1 -fsigned-char" ./configure
make clean
make
make install
)</code></pre>

I didn't make any difference in the PGIO run. Of course, this may change with a read-write workload (more spinlocks) with checksum.

Note that I compiled with the default (empty) CFLAGS and then gcc was called with -march=armv8-a+crc (and -moutline-atomics is the default) so I'm in the same situation with run-time detection. Because the GCC &gt;=10 behaviour has been backorted by Amazon to the GCC 7 in Amazon Linux 2. This was not clear for me initially (I got this clarified <a href="https://github.com/aws/aws-graviton-getting-started/issues/107" rel="noopener" target="_blank">here</a>).

By the way, Aurora on Graviton2 is still compiled with GCC 7.4
<a href="https://blog.dbi-services.com/wp-insides/uploads/sites/2/2021/03/Screenshot-2021-03-15-091805-1.jpg"><img src="https://blog.dbi-services.com/wp-insides/uploads/sites/2/2021/03/Screenshot-2021-03-15-091805-1.jpg" alt="" width="1123" height="342" class="aligncenter size-full wp-image-48465" /></a>

<b>Update 15-MAY-2021</b>: I have rephrased a few things here which were not clear (even for myself) but I'll write more on PostgreSQL on ARM, and on benchmarks in general. <a href="http://blog.pachot.net" rel="noopener" target="_blank">http://blog.pachot.net</a> should send to the right place (or <a href="https://twitter.com/FranckPachot" rel="noopener" target="_blank">@FranckPachot</a> twitter of course)