Rails 3.2 RC1: Faster dev mode & routing, explain queries, tagged logger, store
weblog.rubyonrails.org
weblog.rubyonrails.org
Now, if we could just get someone to commit the fix for the debugger under Ruby 1.9.3. Not being able to debug, or at least having to work too hard at it, is really a drag on my productivity and is keeping me from moving to the newer faster stuff everywhere. Come on Mr. Moseley, release ruby-debug-base19 v0.11.26 already!
I had a similar issue, which turned out to be a bad Rails plugin, which maintained a few unnecessary pointers to my model classes. The small plugin caused a 20+MB per request leak in development. I rewrote the piece of functionality I needed from the offending module & the issue went away entirely.
Sadly, there isn't really decent memory profiler support to help you track it down. I found the issue by running `git bisect run` with a little script which restarted the server, beat on it a bit with `ab` and then printed memory usage with `ps`. Took me about 10 minutes to track it down to the exact offending commit.
#!/bin/bash
root="/path/to/your/code"
user='postgres'
db='dev'
schema="$root/db/schema.sql"
pg_dump -U $user $db \
--schema=public \
--schema-only \
--no-owner \
--no-privileges \
--file $schema
pg_dump -U $user $db \
--table public.schema_migrations \
--no-owner \
--data-only \
--insert \
>> $schema
Then a trivial `dropdb`, `createdb`, `psql < db/schema.sql`And then a small script with 4 or 5 curl calls can get enough data into the database to drive some tests.
Basically, can someone give me a way back into pre-3.1 asset pipeline slowdown ?
This has been the single biggest complaint against Rails 3.1 if you google for it. For e.g. take a look at http://stackoverflow.com/questions/8084006/serve-assets-dire...
Similar questions have been addressed by either installing rails-dev-tweaks or by pre-compiling assets - which is then a problem if you're actually working on the UI/JS - which is where half the dev time is usually spent.
Anyway, yes I think that this release fixes those issues. However, there appears to be a problem with the SASS @import command and partials[1] so I haven't been able to fully test my system yet with all it's assets working properly.
curl get.pow.cx | VERSION=0.4.0-pre sh
If you are interested, I posted in the comments to this gist (https://gist.github.com/1184843#gistcomment-65875) some changes that we made to our SASS files to markedly increase the compile time.
For us it went from (depending on the machine) something like 40s down to a <5 seconds which was a massive improvement (CSS development was almost impossible for a while there).
They have indeed been crippling for front-end development, and majorly under-reported since this summer. So if you're facing any of these issues, please participate in the GitHub Issues threads I linked above and help the relevant teams diagnose/improve the problems.
bash < <(curl -L https://raw.github.com/gist/1333785)I'm using schema separation for a multitenant application, and it looks like I'll be able to remove at least 4/6 hacks to make rails support that functionality.
The result of this is that I have dozens of tables duplicated across n schemas. In Rails 3.1, the Postgres query cache, exec cache, and the identity map do not account for this, nor does table_exists?, and the connection pool would often check out a new connection without preserving the search path.
In Rails 3.2, most of these are fixed. The exec cache, query cache, and table_exists? now observe the search_path properly, and I believe the connection pool behaves better, though I haven't had time to confirm that. The identity map still doesn't understand, which I've filed an issue for: https://github.com/rails/rails/issues/4044
I'm really happy with this pattern for multi-tenant apps. It gives me a lot more confidence that no data leaks will happen than scoping queries, and the performance increase is significant with large datasets (unless of course, for some reason, you need to aggregate across tenants). It's nice to see rails supporting this better.
The sixth patch I had hacks support for iterating over multiple schemas to migrations. I add "schema_set :public or :tenant" to the top of my migration, and it runs either once on the public schema, or n+1 times on my template_tenant schema and my tenant_X schemas. It wouldn't make sense for this part to be in rails proper at the moment.
http://blog.jerodsanto.net/2011/07/building-multi-tenant-rai...
EDIT: This is my migration hack: https://gist.github.com/1f5e67b018d304dd1198 . Most of the SchemaUtils/Schema stuff is just wrappers around setting the schema_search_path.
It should be a lot easier to go from 3.0 to 3.1 or 3.2 and hopefully from 3.0 to 4.0.
My favorite bug during the upgrade: Someone decided (long ago) it'd be a good idea to store a Marshalled object in the session-cookie. One class serialized therein disappeared in Rails 3.1. Result? Any and all requests with a session-cookie bomb out with an unmarshall error.
tldr: Make sure to rename your session cookie before rolling out the upgrade. This logs out all users but is still more desirable than the alternative...
I moved all dependency management from config.gem over to Bundler, and haven't had a dependency issue since.
Generally I like Arel, but the changed behavior around default_scope is maddening. And I've found several pretty big bugs that have been annoying to work around.
Can you expand on this?
The way around this is to use :reorder, but :reorder doesn't work the same way and can generate invalid SQL if you're prefetching included associations. So, you're left with :unscoped, but that's insanely insecure because it drops any foreign key scopes you had in place.
Likewise, it only normalizes identical order clauses if you use the exact same casing. This one is a bit more esoteric, but if your default_scope is to order by "id asc" and you reorder by "id ASC", Arel will produce "ORDER BY id asc, id ASC". If they match in case, however, it'll be normalized to a single clause.
I haven't found the time to attempt a proper fix to any of these problems yet.
We use user-defined functions in Postgres, and I have the same complaint - in theory, the move toward composable relations is great, but in practice, there are so many hitches and gotchas and prior assumptions and backwards-compatibility requirements that it's never clean.
I'm quite happy about this, as the initial development boot time is what's been bothering me most lately.
8.5s to 6.6s on my laptop (with SSD). Nice!
Combined with rspec-rails 2.8.0.rc2 (which includes some Rails 3.2-related changes), I saw my test suite go from ~2.5s (Rails 3.2.0.rc1 w/ rspec 2.7.x) to ~0.43s (Rails 3.2.0.rc1 w/ rspec 2.8.0.rc2).
Ruby 1.9.3p0 across the board.
But there was a definite increase with Rails 2.3 as well. :)
Great talk, also.
I love rails :)