PG::Result: Initialize all on-demand values before freeze#674
Merged
Conversation
5fe259e to
f9cd50f
Compare
... and do not use tuple_hash. Multiple Ractor instances could otherwise initialize them simultanly, leading to data races.
It results in the same performance, but is simpler.
To allocate the necessary memory from the start.
The PG::Result spec fails with pg-1.6.2 like so:
1) PG::Result should be distributable to Ractors
Failure/Error: expect( arr ).to eq( (1..100).to_a.flat_map{|a| [{"f" => a.to_s}, {"f" => a.to_s}] } )
expected: [{"f" => "1"}, {"f" => "1"}, {"f" => "2"}, {"f" => "2"}, {"f" => "3"}, {"f" => "3"}, {"f" => "4"}, {"...> "97"}, {"f" => "98"}, {"f" => "98"}, {"f" => "99"}, {"f" => "99"}, {"f" => "100"}, {"f" => "100"}]
got: [{"f" => "1"}, {"f" => "1"}, {"f" => "2"}, {"f" => "2"}, {"f" => "3"}, {"f" => "3"}, {"f" => "4"}, {"...> "97"}, {"f" => "98"}, {"f" => "98"}, {"f" => "99"}, {"f" => "99"}, {"f" => "100"}, {"f" => "100"}]
(compared using ==)
Diff:
@@ -165,9 +165,9 @@
{"f" => "83"},
{"f" => "83"},
{"f" => "84"},
- {"f" => "84"},
{"f" => "85"},
{"f" => "85"},
+ {"f" => "85"},
{"f" => "86"},
{"f" => "86"},
{"f" => "87"},
@@ -179,7 +179,7 @@
{"f" => "90"},
{"f" => "90"},
{"f" => "91"},
- {"f" => "91"},
+ {"f" => "92"},
{"f" => "92"},
{"f" => "92"},
{"f" => "93"},
./spec/pg/result_spec.rb:61:in 'block (2 levels) in <top (required)>'
./spec/helpers.rb:64:in 'block in PG::TestingHelpers.included'
ae51e1e to
56bcdb7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Multiple Ractor instances could otherwise initialize them simultanly, leading to data races.