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

precompile: fix the slowness #18191

Merged
merged 4 commits into from
Aug 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/manual/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,14 @@ A few other points to be aware of:
4. WeakRef objects and finalizers are not currently handled properly by the serializer
(this will be fixed in an upcoming release).

5. It is usually best to avoid capturing references to instances of internal metadata objects such as
Method, LambdaInfo, MethodTable, TypeMapLevel, TypeMapEntry
and fields of those objects, as this can confuse the serializer
and may not lead to the outcome you desire.
It is not necessarily an error to do this,
but you simply need to be prepared that the system will
try to copy some of these and to create a single unique instance of others.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you give some concrete examples? most of the metadata objects you describe are (undocumented) internal system details.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


It is sometimes helpful during module development to turn off incremental precompilation.
The command line flag ``--compilecache={yes|no}`` enables you to toggle module precompilation on and off.
When Julia is started with ``--compilecache=no`` the serialized modules in the compile cache are ignored when loading modules and module dependencies.
Expand Down
9 changes: 8 additions & 1 deletion src/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ static jl_lambda_info_t *jl_copy_lambda(jl_lambda_info_t *linfo)
}

// return a new lambda-info that has some extra static parameters merged in
JL_DLLEXPORT jl_lambda_info_t *jl_get_specialized(jl_method_t *m, jl_tupletype_t *types, jl_svec_t *sp)
JL_DLLEXPORT jl_lambda_info_t *jl_get_specialized(jl_method_t *m, jl_tupletype_t *types, jl_svec_t *sp, int allow_exec)
{
jl_lambda_info_t *linfo = m->lambda_template;
jl_lambda_info_t *new_linfo;
Expand All @@ -565,6 +565,13 @@ JL_DLLEXPORT jl_lambda_info_t *jl_get_specialized(jl_method_t *m, jl_tupletype_t
new_linfo->def = m;
new_linfo->sparam_vals = sp;
}
else if (!allow_exec) {
new_linfo = jl_copy_lambda(linfo);
new_linfo->specTypes = types;
new_linfo->def = m;
new_linfo->sparam_vals = sp;
jl_set_lambda_code_null(new_linfo);
}
else {
new_linfo = jl_instantiate_staged(m, types, sp);
}
Expand Down
4 changes: 2 additions & 2 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,7 @@ void *jl_get_llvmf(jl_tupletype_t *tt, bool getwrapper, bool getdeclarations)
linfo = jl_get_specialization1(tt);
if (linfo == NULL) {
linfo = jl_method_lookup_by_type(
((jl_datatype_t*)jl_tparam0(tt))->name->mt, tt, 0, 0);
((jl_datatype_t*)jl_tparam0(tt))->name->mt, tt, 0, 0, 1);
if (linfo == NULL || jl_has_call_ambiguities(tt, linfo->def)) {
JL_GC_POP();
return NULL;
Expand Down Expand Up @@ -5830,7 +5830,7 @@ extern "C" void jl_init_codegen(void)
#ifdef DISABLE_OPT
.setOptLevel(CodeGenOpt::None)
#else
.setOptLevel(CodeGenOpt::Aggressive)
.setOptLevel(jl_options.opt_level == 0 ? CodeGenOpt::None : CodeGenOpt::Aggressive)
#endif
#if defined(USE_MCJIT) && !defined(LLVM36)
.setUseMCJIT(true)
Expand Down
Loading