Skip to content
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

reinit Main by clearing everything in it after building the sysimg #5746

Closed
wants to merge 1 commit into from

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented Feb 9, 2014

Continuing the discussion started in #5687.

We can't compile the sysimg twice because of old crap left in the Main module. This implements a empty!(::Module) functionality so that Main is left in an almost pristine state after redefining Base.

@vtjnash
Copy link
Member Author

vtjnash commented Feb 9, 2014

See also #1195 and #2385 which this almost addresses.

@timholy
Copy link
Member

timholy commented Feb 12, 2014

Today I gave a demonstration to my lab of some Julia code I've been writing; overall it went well, but everyone was surprised that it took 52 seconds just to load the code before I could start the demo (and then slow performance for the next ~15 seconds while various bits got compiled). Such slow startup times don't help debugging, either.

I'd love to vouch for this PR, but it's out of my league (heck, I don't even understand why the scheduler was related to precompiled packages). Anyone else feel up to it?

@StefanKarpinski
Copy link
Member

The issue was that things had to happen in this order:

  1. load sysimg
  2. save precompiled image
  3. start scheduler
  4. load packages

In order to precompile packages, one wants to move 2 after 4 but 2 had to come before 3 and 4 had to come after 3. The solution was to remove 3 altogether, allowing 2 and 4 to be arbitrarily ordered.

@vtjnash
Copy link
Member Author

vtjnash commented Feb 12, 2014

I think the only person who can evaluate this is Jeff. Unfortunately, he can be a hard man to contact.

@timholy
Copy link
Member

timholy commented Feb 12, 2014

Well, I know he's been working hard on scheduler-related issues, and perhaps the dust hasn't even settled from that yet. I may be able to chip away at those load times a bit by some code-partitioning.

@StefanKarpinski, thanks for the explanation.

@timholy
Copy link
Member

timholy commented Feb 12, 2014

Rather than packing everything into the julia binary, is it at all practical to go with a more modular approach: have precompile("Gtk") write a binary file to ~/.julia/Gtk/deps that gets loaded (when available) by using Gtk?

@vtjnash
Copy link
Member Author

vtjnash commented Feb 12, 2014

That is much much harder. You can pack stuff in now -- just need a base sys0.ji image to build from which doesn't have the extra stuff

@timholy
Copy link
Member

timholy commented Feb 12, 2014

Good point, I'll do that locally.

@JeffBezanson
Copy link
Member

I don't think mutating the module is a good way to do this. We probably want to do what we're doing with Base, just one level up. There could be a clear() function that basically re-runs the snippet in init.c that sets up Main. This is pretty close to what many people expect clear() to do, but it's hard to think of a name that does justice to the level of violence inflicted by this function.

@quinnj
Copy link
Member

quinnj commented Feb 12, 2014

murder(), slaughter(), completely_wipe_out()....... :)

@StefanKarpinski
Copy link
Member

EXTERMINATE!!!()

@staticfloat
Copy link
Member

@StefanKarpinski I was scrolling down to write that suggestion, only to see that another great mind had already thought alike. ;)

@vtjnash
Copy link
Member Author

vtjnash commented Feb 12, 2014

Nice use of ! In the method name, Stefan

I tried that first Jeff, but ran into a lot of problems since it requires changing the binding of almost everything so that Base and Core gets reparented in the new Main.

@Keno
Copy link
Member

Keno commented Feb 12, 2014

How about Base.(( symbol(char(0x1f4a3)) ))(m::Module) (github won't allow me to type the actual character)

@StefanKarpinski
Copy link
Member

There's something hilarious about providing this functionality but making people type unicode to use it.

@JeffBezanson
Copy link
Member

I didn't think the parent module of Core mattered much --- what happens if we just switch jl_core_module->parent ? Base shouldn't need to be reparented; we can make a new Main module and put the new Base in the new Main.

@vtjnash vtjnash mentioned this pull request Feb 13, 2014
@vtjnash
Copy link
Member Author

vtjnash commented Feb 13, 2014

It wasn't likely the Core module itself that caused issues. And I'm not saying it is completely impossible, but it seemed more fragile that way, so I switched approaches. Perhaps it was just that I tried to also replace Core, but it seemed that the jl_binding_t references from locations like Base.Main, were just easier to resolve if Base.Main didn't suddenly try to move while pretending not to move.

Perhaps instead we could architect:

module Main
    module Core end
    module Base end
    module This_Is_All_New
        module Main
            module Core end
            module Base end
            module MoreNewStuff_WhichCantSeeMain end
        end
    end
end
Main = Main.This_Is_All_New

@JeffBezanson
Copy link
Member

I'm not sure what "pretending not to move" means. I was thinking

module Main
    module Core end
    module Base end
end

old_main = Main

module Main
    module Core
    module Base
        # new Base defined here
    end
end

@vtjnash
Copy link
Member Author

vtjnash commented Feb 13, 2014

I'm not sure what old_main = Main means there either. Are you suggesting always constructing a new Main module if the user passes the --build flag? Would it be better to just disallow passing -J with --build (and eliminate sys0.ji)?

@JeffBezanson
Copy link
Member

old_main = Main is not really necessary there, it's just keeping a reference to the old Main.

I don't think we can eliminate the 2-stage bootstrap; it could have bad performance implications.

@JeffBezanson
Copy link
Member

Superseded by #5821

@vtjnash vtjnash deleted the jn/reinit_main branch February 15, 2014 00:52
@vtjnash
Copy link
Member Author

vtjnash commented Feb 15, 2014

Thanks

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.

7 participants