Skip to content

Conversation

vlakoff
Copy link
Contributor

@vlakoff vlakoff commented May 1, 2016

Follow-up to #13351. Please note this is very much a WIP and may have important caveats.

Important: we would lose app.env config. But that may be a good thing, things get mixed up because of this setting. Better use app()->environment().

@GrahamCampbell
Copy link
Member

We don't want to load anything if w have cached config for performance reasons.

@GrahamCampbell
Copy link
Member

Only ever read env variables from inside config files.

@vlakoff
Copy link
Contributor Author

vlakoff commented May 1, 2016

  • I'm pretty sure there are people who define custom env variables, and use them outside from config files. They don't encounter errors, up to the day they activate config caching...
  • Do you have more details about config loading performances? I guess dotenv isn't a bottleneck amongst this.
  • The issue is still to be resolved. If you can think of a fix, please be my guest :)

@GrahamCampbell
Copy link
Member

I'm pretty sure there are people who define custom env variables, and use them outside from config files.

That is not allowed anymore for performance reasons, and it would be a bad practice anyway.

@GrahamCampbell
Copy link
Member

Do you have more details about config loading performances? I guess dotenv isn't a bottleneck amongst this.

Yes, it is a bottleneck. We found a 25% throughput increase on the out of the box app when applying these optimizations when prepping for the 5.2 release.

@GrahamCampbell
Copy link
Member

The issue is still to be resolved. If you can think of a fix, please be my guest :)

I don't agree that there exists an issue. Sorry.

@vlakoff
Copy link
Contributor Author

vlakoff commented May 1, 2016

I meant performances of dotenv in particular, amongst the sum of config files + dotenv.

@GrahamCampbell
Copy link
Member

GrahamCampbell commented May 1, 2016

I meant performances of dotenv in particular

Yes, config caching with dotenv vs config cahing without dotenv was the 25% different. The change was actually larger than having config caching enabled!

@GrahamCampbell
Copy link
Member

Summary: dotenv is REALLY slow because it means we have to do disk IO and lots of CPU time. PHP already has internal optimization for loading compiled php files into memory, so requiring php files is inexpensive, That's also why we made the services.json -> services.php change.

@GrahamCampbell
Copy link
Member

Dotenv also has concurrency bugs, and is not suitable for production use. It should only be used to initialize config files like we're using it for in L5.2 really. For that kind of use it's safe.

@vlakoff
Copy link
Contributor Author

vlakoff commented May 1, 2016

app->environment() tries all of these:

1) --env argument
2) callback
    2.1) app.env config
        2.1.1) APP_ENV
        2.1.2) fallback to "production"

Whereas DetectEnvironment::checkForSpecificEnvironmentFile tries only 2.1.1 from the above (and in a kind of hardcoded way).

As showed in #13351, this is a limitation. Also, this is inconsistent and could lead to other bugs.

@vlakoff
Copy link
Contributor Author

vlakoff commented May 1, 2016

Thanks for the above explanations concerning dotenv.

@taylorotwell taylorotwell reopened this May 1, 2016
@vlakoff
Copy link
Contributor Author

vlakoff commented May 11, 2016

No plans to improve this? It's complicated because env and config loading depend on each other…

@vlakoff vlakoff deleted the env branch May 29, 2016 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants