I have a suspicion what's causing this, but would it be possible for you to run a profile (with perf or such) and report the result?
Attached
perf.data.subtran100k.gz is 'perf record -a -g -s -- ' output for the pg_logical_slot_get_changes() query in script 1 for 100,000 subtransactions.
perf.data.createtable5k.gz is 'perf record -a -g -s -- ' output for the pg_logical_slot_get_changes() query in script 2 for 5,000 create tables in one transaction.