Rafael Mendonça França
2bdb4828a8
Merge pull request #51944 from cbldev/main
...
Update permissions policy list with display-capture and keyboard-map
2024-05-29 17:18:43 -04:00
Cyril Blaecke
6cb41bae10
Keep previous CHANGELOG entry
2024-05-29 22:55:27 +02:00
Cyril Blaecke
cba374995c
Update actionpack CHANGELOG
2024-05-29 22:49:59 +02:00
Cyril Blaecke
931d2a890c
Update permissions policy list
2024-05-29 22:40:05 +02:00
Hartley McGuire
f3b154de02
Merge pull request #51943 from louim/main
...
Fix Tuning Performance for Deployment guide link [ci skip]
2024-05-29 15:05:24 -04:00
Louis-Michel Couture
f247a19dc7
Fix Tuning Performance for Deployment guide link [ci skip]
2024-05-29 14:56:40 -04:00
Carlos Antonio da Silva
e12ba4d539
Fix method reference in Active Record changelog [ci skip]
2024-05-29 13:52:16 -03:00
Jean Boussier
ea757ae702
Merge pull request #51924 from Shopify/performance-tuning-guide
...
Add a Rails Guide called "Tuning Performance for Deployment" (second version)
2024-05-29 17:02:48 +02:00
Jean Boussier
f719787c58
Restore automatic detection of processor count in default puma config
...
It has to be reverted because the previous implementation wasn't
cgroup aware so it would often start way too many processes on various
shared hosting platforms.
Thanks to https://github.com/ruby-concurrency/concurrent-ruby/pull/1038
concurrent-ruby 1.3 now offer a cgroups aware method to detect how
many processors we can actually use.
2024-05-29 16:46:51 +02:00
Jean Boussier
23bf7b6807
Add a Rails Guide called "Tuning Performance for Deployment".
...
This guide explains major concurrency and performance principles
for Puma and CRuby.
This is a reworked version of #50949 .
Closes : #50949
Co-authored-by: Noah Gibbs <noah.gibbs@shopify.com>
2024-05-29 16:46:51 +02:00
Xavier Noria
b9f814ad86
Merge pull request #51937 from rails/fxn/nil-uuid
...
Define Digest::UUID.nil_uuid
2024-05-29 14:50:16 +02:00
Xavier Noria
a7d7e3d884
Define Digest::UUID.nil_uuid
2024-05-29 14:41:30 +02:00
zzak
234191c03b
Handle case where script_name is a blank string
...
TBD: where is it being set as ""
wip: add regression test
2024-05-29 21:24:07 +09:00
Jean Boussier
d50fc2202d
Merge pull request #51744 from Shopify/result-rows
...
Index Result rows rather than to convert them into hashes
2024-05-29 08:14:03 +02:00
Jean Boussier
10dfdc5eb1
Index Result rows rather than to convert them into hashes
...
Using the same benchmark as https://github.com/rails/rails/pull/51726
A significant part of the memory footprint comes from `Result#each`:
```
Total allocated: 4.61 MB (43077 objects)
Total retained: 3.76 MB (27621 objects)
allocated memory by file
-----------------------------------
391.52 kB activerecord/lib/active_record/result.rb
retained memory by file
-----------------------------------
374.40 kB activerecord/lib/active_record/result.rb
```
Rows are initially stored as arrays, but `Result#each` convert them
to hashes. Depending on how many elements they contain, hashes use
between 2 and 5 times as much memory than arrays.
| Length | Hash | Array | Diff |
| --------- | --------- | --------- | --------- |
| 1 | 160B | 40B | -120B |
| 2 | 160B | 40B | -120B |
| 3 | 160B | 40B | -120B |
| 4 | 160B | 80B | -80B |
| 5 | 160B | 80B | -80B |
| 6 | 160B | 80B | -80B |
| 7 | 160B | 80B | -80B |
| 8 | 160B | 80B | -80B |
| 9 | 464B | 160B | -304B |
| 10 | 464B | 160B | -304B |
| 11 | 464B | 160B | -304B |
| 12 | 464B | 160B | -304B |
| 13 | 464B | 160B | -304B |
| 14 | 464B | 160B | -304B |
| 15 | 464B | 160B | -304B |
| 16 | 464B | 160B | -304B |
| 17 | 912B | 160B | -752B |
| 18 | 912B | 160B | -752B |
| 19 | 912B | 320B | -592B |
| 20 | 912B | 320B | -592B |
| 21 | 912B | 320B | -592B |
| 22 | 912B | 320B | -592B |
| 23 | 912B | 320B | -592B |
| 24 | 912B | 320B | -592B |
| 25 | 912B | 320B | -592B |
| 26 | 912B | 320B | -592B |
| 27 | 912B | 320B | -592B |
| 28 | 912B | 320B | -592B |
| 29 | 912B | 320B | -592B |
| 30 | 912B | 320B | -592B |
| 31 | 912B | 320B | -592B |
| 32 | 912B | 320B | -592B |
| 33 | 1744B | 320B | -1424B |
| 34 | 1744B | 320B | -1424B |
| 35 | 1744B | 320B | -1424B |
| 36 | 1744B | 320B | -1424B |
| 37 | 1744B | 320B | -1424B |
| 38 | 1744B | 320B | -1424B |
| 39 | 1744B | 640B | -1104B |
| 40 | 1744B | 640B | -1104B |
| 41 | 1744B | 640B | -1104B |
| 42 | 1744B | 640B | -1104B |
| 43 | 1744B | 640B | -1104B |
| 44 | 1744B | 640B | -1104B |
| 45 | 1744B | 640B | -1104B |
| 46 | 1744B | 640B | -1104B |
| 47 | 1744B | 640B | -1104B |
| 48 | 1744B | 640B | -1104B |
| 49 | 1744B | 640B | -1104B |
| 50 | 1744B | 640B | -1104B |
Rather than to convert rows into hashes, we can loopkup the column index
into a single Hash common to all rows. To not complexify the code too much,
rather than to pass the row array and the column index, we wrap both into
an `IndexedRow` object, which uses an extra `40B` object, but that's still
less memory even in the worst case.
After:
```
Total allocated: 4.32 MB (43079 objects)
Total retained: 3.65 MB (29725 objects)
allocated memory by file
-----------------------------------
101.66 kB activerecord/lib/active_record/result.rb
retained memory by file
-----------------------------------
84.70 kB activerecord/lib/active_record/result.rb
```
As for access speed, it's of course a bit slower, but not by much,
it's between `1.5` and `2` times slower, but remains in the 10's of M
iterations per second, so I think this overhead is negligible compared
to all the work needed to access a model attribute.
Also the `LazyAttributeSet` class only access this once, after the
attribute is casted, the resulting value is still stored in a regular
`Hash`.
2024-05-29 07:32:18 +02:00
Justin Ko
80a6291d7f
Add test
2024-05-28 21:13:20 -06:00
Justin Ko
7511c28244
Merge remote-tracking branch 'upstream/main' into issue-51882
2024-05-28 19:22:25 -06:00
Rafael Mendonça França
e2ef1d6818
Merge pull request #50828 from akhilgkrishnan/add-example-for-month-field-tag
...
Add examples for form helper tags [ci skip]
2024-05-28 18:02:40 -04:00
Rafael Mendonça França
e46e56b1f4
Merge pull request #51892 from florin555/fix_pretty_print
...
Make `pretty_print` behave more similar to `inspect`.
2024-05-28 18:00:40 -04:00
Rafael Mendonça França
93f4b6d7a6
Merge pull request #51930 from justinko/issue-51914
...
Improve ActionCable's TestCookieJar interface
2024-05-28 16:24:14 -04:00
Justin Ko
24472e01c1
Improve ActionCable TestCookieJar interface
...
Fixes #51914
2024-05-28 20:09:39 +00:00
Rafael Mendonça França
23151ea1bd
Merge pull request #51934 from jrmhaig/wasm_unsafe_eval
...
Add CSP mapping for 'wasm-unsafe-eval'
2024-05-28 14:53:10 -04:00
Joe Haig
10dc425e8e
Add CSP mapping for 'wasm-unsafe-eval'
...
The `'wasm-unsafe-eval'` keyword for the Content Security Policy allows the
loading and execution of WebAssembly modules without the need to allow unsafe
JavaScript execution via `'unsafe-eval'`. A mapping is added so that the symbol
`:wasm_unsafe_evel` can be used for this keyword in the policy configuration in
`config/initializers/content_security_policy.rb`.
2024-05-28 18:39:48 +00:00
Rafael Mendonça França
bcba3f327a
Use docker.io as the default registry for Ruby images
...
The `registry.docker.com` registry isn't documented and have a delay
when pulling images. The `docker.io` registry is the default registry
for Docker images and is the one used by the Docker CLI.
2024-05-28 18:21:48 +00:00
Rafael Mendonça França
809409ab29
Merge pull request #51925 from zzak/re-51395-proxy_association
...
Make CollectionProxy#proxy_association public API
2024-05-28 13:39:28 -04:00
Vipul A M
31b7b1eade
Merge pull request #51935 from pdxmike/guides-minor-spelling-update
...
Guides: Minor Update To Spelling [ci skip]
2024-05-28 21:27:54 +05:30
Mike Hickman
c6df8baf4b
Update spelling: Getting Start to Getting Started
2024-05-28 16:01:41 +01:00
Jean Boussier
fae23a37df
Merge pull request #51932 from Shopify/relation-model
...
Unify `Relation#klass` and `Relation#model`
2024-05-28 15:00:38 +02:00
Xavier Noria
630fc98709
Rewrite unless/else as if/else
...
I believe it is generally accepted that unless/else is hard to read,
too many negations.
2024-05-28 13:44:13 +02:00
Xavier Noria
2aeb322806
Let's use the delegation to the transaction manager here
...
`within_new_transaction` is delegated to the transaction manager. Let's remove
this explicit receiver to honor the delegation and for consistency with usage
of the also delegated `current_transaction`.
2024-05-28 13:21:10 +02:00
Jean Boussier
9f901b7350
Unify `Relation#klass` and `Relation#model`
...
One is the alias of the other, and have been so for a very long time.
My issue with this is that `klass` is really a bad name, and it's
very confusing when reading code to see a mix of both names being
used.
There is no point officially deprecating either, but inside
Active Record we should consistently only use one, I chose to
use `model` as it's way more descriptive in my opinion.
2024-05-28 11:24:35 +02:00
Justin Ko
155d0afa31
Allow ActiveStorage::Attachment creation with no record attachments
...
FIxes #51882
2024-05-28 01:21:22 -06:00
Jean Boussier
9ce4d4468e
Explictly take a block in Arel `add_bind`
...
Fix: https://github.com/rails/rails/issues/51926
This prevent a false positive warning for unused blocks
on Ruby 3.4-dev.
2024-05-28 08:53:30 +02:00
Jean Boussier
407031f8b8
Merge pull request #50396 from Shopify/stricter-relation-delegation
...
Make the Relation -> Model delegation stricter
2024-05-28 08:47:41 +02:00
Jean Boussier
fd5bd98b34
Make the Relation -> Model delegation stricter
...
In https://github.com/rails/rails/pull/50395 I noticed lots of
methods are delegated from `Relation` to the model. The intent of
this code is to allow using use defined class methods like scopes.
But because of this autmated delegation it allows calling any
`ActiveRecord::Base` class method on a `Relation`, which in itself
may be desireable, however we very wastefully define the delegator
on the first call, and worse we wrap it with a global scope setter.
This also has led to bugs in the past, like https://github.com/rails/rails/pull/51776
So I think we should be more strict about it.
We can't deprecate this behavior because gems might depend on it, however we
can ban it from Active Record's own test suite to avoid regressions.
2024-05-28 08:13:23 +02:00
zzak
7aa7e1e3e1
Make CollectionProxy#proxy_association public API
...
Co-authored-by: Petrik <petrik@deheus.net>
2024-05-28 07:47:43 +09:00
Rafael Mendonça França
f6918a5b5d
Merge pull request #51909 from rails/rm-release-notes
...
Draft of the release notes
2024-05-27 16:39:42 -04:00
Rafael Mendonça França
58883a5f8b
Merge pull request #51371 from theodorton/relation-test-readonly
...
Add `ActiveRecord::Relation#readonly?`
2024-05-27 16:39:30 -04:00
Rafael Mendonça França
b0efe426e7
Edit pass on 7.2 release notes
2024-05-27 19:53:04 +00:00
Theodor Tonum
d28e7c29a2
Add `ActiveRecord::Relation#readonly?`
...
Indicates whether a relation was marked readonly.
2024-05-27 21:51:04 +02:00
Rafael Mendonça França
9232363f4a
Merge pull request #51929 from Skalar/source-reflection-regression
...
Make source_reflection return nil when no name
2024-05-27 15:22:19 -04:00
Theodor Tonum
2364b4243d
Make source_reflection return nil when no name
2024-05-27 21:08:45 +02:00
Yasuo Honda
ae3c93df0c
Merge pull request #51859 from fatkodima/fix-partial_inserts-with-identity-cpk
...
Fix non-partial inserts for models with composite identity primary keys
2024-05-27 21:45:29 +09:00
zzak
db932716a6
Merge pull request #51923 from wonda-tea-coffee/fix-typo-in-puma-config
...
Fix typo
2024-05-27 19:53:18 +09:00
wonda-tea-coffee
e71ba8f914
Fix typo
2024-05-27 18:58:28 +09:00
Yasuo Honda
a658c68093
Merge pull request #51921 from zzak/railties-sqlite-non_existent-test
...
Re-enable railtie non_existent sqlite3 test from #51901
2024-05-27 18:03:18 +09:00
zzak
e2adebef43
Re-enable railtie non_existent sqlite3 test from #51901
2024-05-27 17:34:17 +09:00
David Heinemeier Hansson
1b3fc3c82e
Change asset pipeline default to Propshaft in Rails 8 ( #51799 )
...
* Change asset pipeline default to Propshaft
* Use :all for stylesheets when propshaft is active
* Switch to using propshaft as the default (still need to find a way to tests against sprockets too)
* Fix tests that rely on sprockets being used
* Fix Propshaft tests (#51913 )
* Update railties/test/generators/shared_generator_tests.rb
Co-authored-by: Lázaro Nixon <lazaronixon@hotmail.com>
---------
Co-authored-by: Lázaro Nixon <lazaronixon@hotmail.com>
2024-05-25 20:48:35 -07:00
Petrik de Heus
d0a3e18d4d
Merge pull request #51867 from duffuniverse/add-missed-comma-to-instrumentation-guide
...
[ci skip] Add a comma in the Exceptions section of Active Support Instrumentation guide
2024-05-25 23:29:21 +02:00
Xavier Noria
4cde578c0e
Restore original header for browser version guards
2024-05-25 19:27:30 +02:00