Commit Graph

56358 Commits

Author SHA1 Message Date
Aaron Patterson
02c3867882 speed up string xor operation and reduce object allocations
```
[aaron@TC rails (master)]$ cat xor.rb
a = "\x14b\"\xB4P8\x05\x8D\xC74\xC3\xEC}\xFDf\x8E!h\xCF^\xBF\xA5%\xC6\xF0\xA9\xF9x\x04\xFA\xF1\x82"
b = "O.\xF7\x01\xA9D\xA3\xE1D\x7FU\x85\xFC\x8Ak\e\x04\x8A\x97\x91\xD01\x02\xA4G\x1EIf:Y\x0F@"

def xor_byte_strings(s1, s2)
  s1.bytes.zip(s2.bytes).map { |(c1,c2)| c1 ^ c2 }.pack('c*')
end

def xor_byte_strings2(s1, s2)
  s2_bytes = s2.bytes
  s1.bytes.map.with_index { |c1, i| c1 ^ s2_bytes[i] }.pack('c*')
end

require 'benchmark/ips'
require 'allocation_tracer'

Benchmark.ips do |x|
  x.report 'xor_byte_strings' do
    xor_byte_strings a, b
  end

  x.report 'xor_byte_strings2' do
    xor_byte_strings2 a, b
  end
end

ObjectSpace::AllocationTracer.setup(%i{type})
result = ObjectSpace::AllocationTracer.trace do
  xor_byte_strings a, b
end
p :xor_byte_strings => result
ObjectSpace::AllocationTracer.clear
result = ObjectSpace::AllocationTracer.trace do
  xor_byte_strings2 a, b
end
p :xor_byte_strings2 => result
[aaron@TC rails (master)]$ ruby -I~/git/allocation_tracer/lib xor.rb
Calculating -------------------------------------
    xor_byte_strings    10.087k i/100ms
   xor_byte_strings2    11.339k i/100ms
-------------------------------------------------
    xor_byte_strings    108.386k (± 5.8%) i/s -    544.698k
   xor_byte_strings2    122.239k (± 3.0%) i/s -    612.306k
{:xor_byte_strings=>{[:T_ARRAY]=>[38, 0, 0, 0, 0, 0], [:T_STRING]=>[2, 0, 0, 0, 0, 0]}}
{:xor_byte_strings2=>{[:T_ARRAY]=>[3, 0, 0, 0, 0, 0], [:T_DATA]=>[1, 0, 0, 0, 0, 0], [:T_IMEMO]=>[2, 0, 0, 0, 0, 0], [:T_STRING]=>[2, 0, 0, 0, 0, 0]}}
```
2016-02-08 15:40:25 -08:00
Jon Moss
e6fc78bfbd Merge pull request #23565 from abhishekjain16/fix_grammar
[ci skip] Fix grammar
2016-02-08 18:03:41 -05:00
Abhishek Jain
c2b9a5dbef [ci skip] Fix grammar 2016-02-09 04:16:28 +05:30
Arthur Nogueira Neves
98ed722039 Merge pull request #23534 from bronson/fix-redefined-warning
fix 'method redefined' warnings
2016-02-08 17:19:15 -05:00
Jon Moss
6c785f0df7 Merge pull request #23563 from pra85/patch-2
Fix a typo
2016-02-08 12:40:24 -05:00
Prayag Verma
581c2a6547 Fix a typo
Replace `a` with `an`
2016-02-08 22:40:48 +05:30
Rafael Mendonça França
9b5ae716db Revert "Merge pull request #23562 from Azzurrio/patch-1"
This reverts commit 8c3cca5e113213958469b1cec8aa9a664535251a, reversing
changes made to 9dcf67c4da35b165301865d9721da1d552f7e03f.

Reason: https://github.com/rails/rails/pull/23562#issuecomment-181442569
2016-02-08 14:09:29 -02:00
Kasper Timm Hansen
8c3cca5e11 Merge pull request #23562 from Azzurrio/patch-1
Update rails-html-sanitizer version to  v1.0.3
2016-02-08 16:43:07 +01:00
Karim El-Husseiny
ec82c13dd4 Update rails-html-sanitizer version to v1.0.3
rails-html-sanitizer 1.0.2 is vulnerable: https://groups.google.com/d/msg/rubyonrails-security/uh--W4TDwmI/m_CVZtdbFQAJ
2016-02-08 17:04:31 +02:00
प्रथमेश Sonpatki
9dcf67c4da Merge pull request #23560 from prathamesh-sonpatki/rm-rails-4-from-assets-guide
Remove references to Rails 4 from assets guide [ci skip]
2016-02-08 19:54:00 +05:30
Kasper Timm Hansen
3b693dfb93 Merge pull request #23552 from bronson/revert-dev-cache
revert dev:cache to rake task, fixes #23410
2016-02-08 15:21:40 +01:00
Vipul A M
d3150c8106 Merge pull request #23558 from kamipo/add_numeric_type_in_doc
Add numeric type in the doc [ci skip]
2016-02-08 10:52:58 +05:30
Ryuta Kamizono
40fd56052b Add numeric type in the doc [ci skip]
Follow up to #23508.
2016-02-08 14:17:23 +09:00
Prathamesh Sonpatki
abef3c2b0d Remove references to Rails 4 from assets guide [ci skip] 2016-02-08 08:57:02 +05:30
प्रथमेश Sonpatki
e8580c63db Merge pull request #23556 from y-yagi/remove_faye-websocket_from_readme
remove `faye-websocket` dependency from README [ci skip]
2016-02-08 08:24:51 +05:30
yuuji.yaginuma
3546b3f0d4 remove faye-websocket dependency from README [ci skip]
`faye-websocket` gem is no longer used from 322dca293b3716ccaa09e7e82046e539b0d2ffda.
2016-02-08 11:47:03 +09:00
Jon Moss
2b18bd5ffa Merge pull request #23554 from romaimperator/update_action_cable_config_example
config examples for ActionCable now use Rails.application.config.action_cable
2016-02-07 21:24:10 -05:00
Richard Schneeman
8af52c0655 Merge pull request #23559 from mabras/patch-1
update turbolinks url [ci skip]
2016-02-07 20:25:52 -05:00
mabras
f83d57d3e1 update turbolinks url [ci skip] 2016-02-08 03:17:31 +02:00
Sean Griffin
a29a41fe54 Merge pull request #23547 from kamipo/schema_type_returns_symbol
`schema_type` returns symbol rather than string
2016-02-07 16:33:33 -07:00
Daniel Fox
0ec48ab0cb config examples for ActionCable now use Rails.application.config.action_cable
Some existing examples used ActionCable.server.config but for
configuring allowed_request_origins that is overridden in development
mode. The correct place to set that is
Rails.application.config.action_cable which the ActionCable initializer
loads from. I thought the other two examples should be changed as well
just in case a default value that would override a configured value is
introduced for either log_tags or disable_request_forgery_protection in
the future.
2016-02-07 17:02:47 -06:00
Scott Bronson
ba2aea9807 revert dev:cache to rake task, fixes #23410 2016-02-07 14:32:43 -08:00
Sean Griffin
5ccf8a9853 Merge pull request #23508 from meinac/add_numeric_type_into_migrations
Added numeric helper into `SchemaStatements` for MySQL and PostgreSQL
2016-02-07 15:31:29 -07:00
Jon Moss
76c42383c7 Merge pull request #23531 from coldnebo/docfix
doc changes to clarify asset pipeline
2016-02-07 16:57:17 -05:00
Larry Kyrala
5015215f9d doc changes
for rails/rails#23431

       modified:   guides/source/asset_pipeline.md
* description of asset combination from apps and gems, e.g. jquery-rails
* after @vipulnsward's related change rails/rails#23479
  correction: --skip-sprockets will prevent all of these gems, not just sass-rails and uglifier

       modified:   guides/source/working_with_javascript_in_rails.md
* noted that rails.js requires the asset pipeline

[ci skip]
2016-02-07 15:42:21 -05:00
Matthew Draper
15f6ad3adc Merge pull request #23532 from matthewd/live-interlock
Hand off the interlock to the new thread in AC::Live
2016-02-08 06:42:49 +10:30
Ryuta Kamizono
bf25ab9523 schema_type returns symbol rather than string
A return value of `schema_type` is used by:

1. primary key type: using as `symbol.inspect`
2. normal column type: using as `symbol.to_s`

It is better to return symbol.
2016-02-08 04:28:38 +09:00
Matthew Draper
11579b8306 Manual yield doesn't block new shares 2016-02-08 05:30:53 +10:30
Matthew Draper
fe7d77cc01 Test the happy path for recursive yields too 2016-02-08 05:30:10 +10:30
thedarkone
5d9e591313 Fix a nonsensical ShareLock test. 2016-02-07 19:13:16 +01:00
David Heinemeier Hansson
7e35cb2987 Add SVG as a default mime type 2016-02-07 15:34:13 +01:00
Matthew Draper
d2c671e3cf Eagerly reacquire when start_sharing is nested inside yield_shares
A full write-preferring wait can lead to deadlock.
2016-02-08 00:36:21 +10:30
Vijay Dev
e2bc819f56 Merge pull request #23540 from vipulnsward/publish-api-apps-doc
Publish guide on "Using Rails for API-only Applications"
2016-02-07 18:20:22 +05:30
Vipul A M
38f6d4e818 Publish guide on "Using Rails for API-only Applications"
Fixes #23322
[ci skip]
2016-02-07 15:28:16 +05:30
Vijay Dev
9a9587ff30 Separate for new and existing applications clearly
[ci skip]
2016-02-07 07:25:03 +00:00
Vijay Dev
bef16522db Merge branch 'master' of github.com:rails/docrails 2016-02-07 07:14:50 +00:00
Vijay Dev
87f060a7ee fix indentation 2016-02-07 07:12:16 +00:00
Scott Bronson
73d1975810 fix 'method redefined' warnings 2016-02-06 18:24:10 -08:00
Mehmet Emin İNAÇ
aa38f7d615 Added numeric helper into migrations.
With this addition, you can add a column into the table like:

```
  create_table(:numeric_types) do |t|
    t.numeric :foo, precision: 10, scale: 2, default: 2.0
  end
```

The result of the migration above is same with:

```
  create_table(:numeric_types) do |t|
    t.decimal :foo, precision: 10, scale: 2, default: 2.0
  end
```
2016-02-07 03:22:03 +02:00
Jon Moss
5b1f3e5b75 Merge pull request #23533 from y-yagi/fix_typo_in_assert_enqueued_jobs_example
fix typo in `assert_enqueued_jobs` example [ci skip]
2016-02-06 19:48:16 -05:00
yuuji.yaginuma
6809758bc6 fix typo in assert_enqueued_jobs example [ci skip] 2016-02-07 09:12:19 +09:00
thedarkone
9f2df7856d AS::Conc::ShareLock#yield_shares tests. 2016-02-07 01:01:51 +01:00
Matthew Draper
3e4a69e52d Hand off the interlock to the new thread in AC::Live
Most importantly, the original request thread must yield its share lock
while waiting for the live thread to commit -- otherwise a request's
base and live threads can deadlock against each other.
2016-02-07 08:32:27 +10:30
Sean Griffin
8526e9bed2 Merge pull request #23519 from kamipo/mariadb_does_not_support_json_type
MariaDB does not support JSON type
2016-02-06 14:44:45 -07:00
Kasper Timm Hansen
4e4bcae084 Avoid coupling Action Pack to Railties.
Referencing Rails.env without checking if it's defined couples
us to Railties.

Fix by avoiding the line breaks if we don't have an env check
to rely on.
2016-02-06 22:28:59 +01:00
Rafael França
495ec33d08 Merge pull request #23529 from syamilmj/remove_unused_method
Remove unused private method
2016-02-06 18:47:48 -02:00
Syamil MJ
04021c4b78 Remove unused private method 2016-02-07 04:07:48 +08:00
Sean Griffin
f611e59cb1 Merge pull request #23520 from kamipo/remove_duplicated_require_arel
Remove duplicated `require 'arel'`
2016-02-06 08:18:16 -07:00
Ryuta Kamizono
d9bdc2f9ef MariaDB does not support JSON type
Fixes #22980.
2016-02-06 23:14:41 +09:00
Eileen M. Uchitelle
b9a95456a5 Merge pull request #23517 from gsamokovarov/yay-youre-on-rails
Replace old Rails greeting references
2016-02-06 08:45:15 -05:00