Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
base system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
7 Jun 2012 at 03:44 UTC
Updated:
29 Jul 2014 at 20:46 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
msonnabaum commentedDrupal\Core and Drupal\Component are not registered as fallbacks, Drupal is.
I think it's a fine idea though to register them explicitly. I don't think it's necessary to remove the fallback though. Separate issue.
Comment #2
msonnabaum commentedActually, damnit, Rob's right. We can get rid of the fallback. It just means we can't have classes in the \Drupal namespace, which seems reasonable. Anything we might put there should go in \Drupal\Core or \Drupal\Component.
Comment #3
msonnabaum commentedOops, got ahead of testbot.
Comment #4
cweagansLooks like testbot is happy with it, and it looks pretty straightforward. I say yes, and it looks like msonnabaum has voiced his approval as well.
Comment #5
tstoecklerCan we drop the escaping in single-quoted strings, pretty plz? :-)
Comment #6
tstoecklerThat was a crosspost. Didn't want to go to needs work.
Comment #7
robloachWas following UniversalClassLoader->findFile(), but I'm indifferent :-) . Same patch, without the escaped backspaces.
Comment #8
dries commentedDid you happen to measure how much cost savings this provides? Regardless of any benchmark results, this makes a lot of sense to me.
Comment #9
msonnabaum commentedI haven't benchmarked it, but it's not hard to predict what it will do. The initial description of what this does isn't correct though. The is_file() for the fallback only gets called if the the class isn't found in the registered namespaces. The idea being that you register all the module namespaces, so the only thing that gets through to the fallback is core. I don't believe this patch will save us any is_file calls.
What this patch *does* save us however is a bunch of calls to strpos when we're loading core classes. This comes at the cost of being able to register a class in the \Drupal namespace, outside of \Core and \Component, which doesn't seem like a big loss. We could actually keep the fallback if we thought we wanted that, and the rest of this patch would have the same benefit.
Comment #10
catchHere's before/after xhprof screenshots, results in 1/6th the number of calls to strpos(), which at the moment means 1,000 less calls (it's likely to be a lot more than that by the time we get to release).
Comment #10.0
catchUpdated issue summary.
Comment #11
chx commentedI am severely tempted to mark this as duplicate in favor of #1658720: Use ClassLoader instead of UniversalClassLoader but of course first getting this won't hurt. But, it will be ripped out soon anyways :)
Comment #12
robloachAgreed.
Comment #13
sunThis patch was ready, the other one is far from being there.
I don't understand why this was marked as duplicate instead of simply committing it.
Re-rolled against HEAD. This looks RTBC to me.
Comment #14
robloachComment #15
cweagansYeah, definitely RTBC.
Comment #16
cweagansAlso, this is blocking #1658720: Use ClassLoader instead of UniversalClassLoader
Comment #17
webchickOk, cool. Looks like the benchmarks in #10 show a nice improvement on # of function calls here.
Committed and pushed to 8.x.
Comment #18.0
(not verified) commentedUpdated issue summary.