-
-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explicit require template engine to prevent warning #54
Conversation
@@ -1,4 +1,9 @@ | |||
require 'tilt' | |||
SUPPORT_ENGINE = %w( | |||
haml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should include haml
. There are many people out there don't use it. We let user explicitly require if needed
Changes Unknown when pulling 20d6ff6 on huydx:master into * on lotus:master*. |
👍 |
Changes Unknown when pulling c7685bd on huydx:master into * on lotus:master*. |
Changes Unknown when pulling 6f95a08 on huydx:master into * on lotus:master*. |
@huydx I don't think suppressing an eventual exception is a good idea. Suppose that we want to use HAML, but we haven't included it in the You make the assumption that the file extension corresponds to the library. This isn't a general rule of thumb. Please check Tilt README and you'll find soon that files with If we want to have a solid implementation for this we should introspect |
@jodosha i agree that handling this behavior in all cases seems not to be a good way. We need warning to tell user to require the library explicitly. |
@huydx TL;DR This is only an annoying issue for the test suite. Let's leave things as they are. Lotus loading modelWhen Lotus::View is used in standalone mode, we explicitly ask developers boot the framework in a thread-safe context. When we load a Lotus application, the internal loader wraps all those operations with a In both the production scenarios above, adapters are autoloaded, but in a safe context. Tilt isn't aware of this sane way that we use to load it. Its vision of the world is limited to the autorequire, which is a worrying issue in case you don't design those mechanisms carefully. Test suiteWhy we don't explicitly require those adapters in tests? Because we don't need to. As mentioned above, Lotus has a safe way to load frameworks and applications. At the same time, we want to assert the Tilt will keep to autoload those adapters. Leaving tests as they are, lets us to notice ASAP if something in Tilt has changed. What to doBecause those warnings are only generated during the tests, I'm for leaving the things as they are. An alternative would be to silence those warnings during for test fixtures. But this may hide other important messages that come from Tilt. /cc @joneslee85 |
@jodosha as lotus loader already wrapped all loading progress in a mutex, i think it's ok to leave things as they are. As well as warning display exactly explicit what it should be, this issue should be closed. |
@joneslee85 This is all yours 💃 |
Also remember that 'require' is rather expensive operation and it's better to avoid it inside methods, especially rather often called initializer. I was going to prepare benchmarks for this, but I see it's not going to be merged anyway ; ) |
@killapl please feel free to bench this, I'd love to see the difference. And yes, this is likely to be merged after another round of review ;) |
@killapl @joneslee85 Please remember that This doesn't affects the runtime. |
Slowing down the startup is a legitimate concern. I will compile down a benchmark for this (hopefully) tomorrow. |
A quick benchmark results in:
Which is around 25% slowdown, or in another words, 0.16s for 20k template loads. This is the case in ruby 2.0.0 and 2.1.3, problem I was thinking must have been relevant in older rubies. I suppose this kind of performance regression is ok if it solves an actual problem. Also, sorry for the delay, builders cut of my internet connection for a couple of days: ( EDIT Mentioning @jodosha @joneslee85 |
@killapl In other words a Real world example. At work we have |
In one of my previous projects we used this method:
And we found out that using just
is way faster beacuse of require. But this was millions of calls and 1.9.3 times, where #require was O(n) if I remember correctly. Well, better checked then sorry: ) |
@killapl I'm confused, what's the relationship between mkpath and this topic? |
There is a require call in mkpath, just like this PR is adding. |
I think the solution here is to have devs to explicitly require the tilt engine during the loading of the code. |
Implicit require engine seem to be a non thread-safe way