Code Monkey home page Code Monkey logo

Comments (4)

kraih avatar kraih commented on June 5, 2024 2

Late loading seems like it would be bad for prefork memory usage. I'd be very sceptical of any PRs in that direction and would want to see data on memory usage for various deployment scenarios.

from mojo.

jberger avatar jberger commented on June 5, 2024 1

While I don't generally feel we need to micro-optimize module loading across the stack, I guess I can see that there are a few dependencies in Mojo::Util that could be easily late-loaded when needed and which are rarely needed unless in specific contexts. I would consider supporting a PR (good for first timers?) that late-loads some of those rarely used dependencies specifically in Mojo::Util.

[Edit: changed from implied promise to support to consider supporting]

from mojo.

jberger avatar jberger commented on June 5, 2024 1

In general that would be true, however, at least Pod::Usage would rarely need to be early-loaded for preforking. I guess I could argue GetOpt::Long either way, though in a non-webapp/Mojo::UserAgent context it would certainly seem to be a win.

On the other hand, it might make things a bit harder for say fat-packing deployments. Missing dependencies because they weren't detected at load-time. Though on the other-other hand, core modules like Pod::Usage and GetOpt::Long don't have to be fat-packed anyway.

I've been debating whether say the Socket dependencies in network_contains would be worth late-loading, but yes, that would suffer from a preforking perspective. All of this is very interesting. @petdance do you have numbers on what the memory usage penalty is for those?

from mojo.

petdance avatar petdance commented on June 5, 2024

I don't have any memory usage penalty numbers, because I wasn't even at that point yet. So far, it's just a "Hmm, why is that here?"

Every so often I do a survey of modules that are loaded in our preloaded web app. Currently, we have 983 from Algorithm::Verhoeff to XML::Xerces. The goal is to make sure that everything gets early loaded (through a startup script if necessary) vs. late loaded. (I also make sure that there are no Test::* modules that get loaded somehow.)

While perusing the list, I was surprised to see the modules I mentioned above: Getopt::Long and the six Pod::*, since nothing in the app would every do anything with either of them. I tracked down what was bringing them in (since it wasn't in our code tree). (Thanks to Devel::TraceLoad!). And then I wrote this issue up.

So, no, I'm not saying "OMG your preloading is ruining my app!!11!1!!!". On the other hand, I could see it becoming a problem in the future pretty easily just by having something added to Mojo::Util. That's why my first thought, as someone who knows not much about Mojo, was to split CLI-only tools into Mojo::Util::CLI.

from mojo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.