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

improve precompiles #20793

Merged
merged 1 commit into from
Mar 28, 2017
Merged

improve precompiles #20793

merged 1 commit into from
Mar 28, 2017

Conversation

JeffBezanson
Copy link
Member

  • Be able to print any type in parse-able syntax. This lets us precompile many more things, such as closures, more operators, types containing Symbol("text/plain"), etc.
  • Put the code for printing things to precompile in a better place. We want to print the observed concrete types that led to compilation, not something else (previously precompile.jl contained some abstract types, which the precompile function actually ignores to avoid poisoning the cache).
  • The precompile statements needed to be updated for 0.6 anyway.

The system image is a bit bigger after this, but the repl is really snappy.

Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

what's the performance of the usual using DataFrames tests (from an empty lib code cache) after this change?

src/rtutils.c Outdated
n += jl_printf(out, ".");
if (!hidden) {
n += jl_printf(out, ".");
if (globfunc && !jl_id_start_char(u8_nextchar(sn,&i))) {
Copy link
Member

Choose a reason for hiding this comment

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

missing spaces after a handful of the ,'s in here

src/rtutils.c Outdated
@@ -526,11 +528,44 @@ static size_t jl_static_show_x_(JL_STREAM *out, jl_value_t *v, jl_datatype_t *vt
}
else if (vt == jl_datatype_type) {
jl_datatype_t *dv = (jl_datatype_t*)v;
if (dv->name->module != jl_core_module) {
jl_sym_t *globname = dv->name->mt != NULL ? dv->name->mt->name : NULL;
int globfunc = globname && jl_get_global(dv->name->module, globname) &&
Copy link
Member

Choose a reason for hiding this comment

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

jl_get_global can mutate m & print deprecation warnings

Copy link
Contributor

Choose a reason for hiding this comment

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

jl_get_global can also allocate?

else if (globfunc) {
n += jl_printf(out, "typeof(");
}
if (dv->name->module != jl_core_module || !jl_module_exports_p(jl_core_module, sym)) {
Copy link
Member

Choose a reason for hiding this comment

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

jl_module_exports_p can allocate and can't be used here (or should be fixed not to allocate?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes I can fix it not to allocate.

@JeffBezanson
Copy link
Member Author

I enabled TRACE_COMPILE and used the repl with stderr redirected to a file. However it looks like this will not work, since various closures seem to end up with different compiler-generated names on different platforms. I don't know exactly why, but with any platform-conditional code it's bound to happen.

@KristofferC
Copy link
Member

FWIW, the REPL feels very snappy indeed!

@kshyatt kshyatt added the compiler:precompilation Precompilation of modules label Feb 24, 2017
@JeffBezanson
Copy link
Member Author

Comments addressed.

I manually removed the closures. Hopefully there will still be a bit of improvement.

@ararslan
Copy link
Member

Bump. @JeffBezanson, we you able to determine what the performance is of using DataFrames as @vtjnash asked in his review?

src/rtutils.c Outdated
n += jl_printf(out, ":%s", jl_symbol_name((jl_sym_t*)v));
char *sn = jl_symbol_name((jl_sym_t*)v);
// TODO check for valid identifier
int quoted = strchr(sn,'/') && strcmp(sn,"/") && strcmp(sn,"//") && strcmp(sn,"//=");
Copy link
Member

Choose a reason for hiding this comment

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

missing spaces after the ,'s here too

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok... this isn't in the formatting guidelines though.

@JeffBezanson
Copy link
Member Author

I tried but I haven't been able to get DataFrames to load on master yet.

@ararslan
Copy link
Member

I haven't been able to get DataFrames to load on master yet.

Ah, yeah... Try checking out DataArrays to master then checking out DataFrames to anj/06.

@JeffBezanson
Copy link
Member Author

Ok, with this change precompiling DataFrames goes from 44 seconds to 50 seconds. Does that mean too many precompiles or not enough?

@vtjnash
Copy link
Member

vtjnash commented Mar 6, 2017

DataFrames goes from 44 seconds

Is this a recent regression? The only acceptable answer here is < 20s.

@JeffBezanson JeffBezanson added this to the 0.6.0 milestone Mar 17, 2017
@JeffBezanson
Copy link
Member Author

Adding to milestone since updating precompiles should go with the release process, and also to remind us to look at the DataFrames compile time regression.

@ararslan
Copy link
Member

As a quick aside regarding DataFrames, it's now installable directly from Pkg.add on 0.6 without having to check out specific branches, as a working release has been tagged.

@JeffBezanson
Copy link
Member Author

DataFrames compile time regression persists.

@JeffBezanson
Copy link
Member Author

Looking at ENABLE_TIMINGS, most of the increases vs. 0.5 seem to be in inference.

- improve static_show to readably print a much larger set of types
- add TRACE_COMPILE option to print `precompile` calls
@JeffBezanson
Copy link
Member Author

Ok, I updated this to just improve the mechanism.

Package load times can be improved a bit by adding precompile statements, and there might be a couple percent slowdown from #20343, but we still have a large performance gap vs. 0.5.

@vtjnash
Copy link
Member

vtjnash commented Mar 28, 2017

OK, thanks. I reviewed the biggest contributors to inference time increase and think I can start working on a patch. That doesn't need to hold this up. It would be good to make sure the new precompile file includes whatever entries that ./julia -e 'using Glob' also lists. I think that should at least prevent further regression in the timing for typical packages.

@vtjnash
Copy link
Member

vtjnash commented Mar 28, 2017

CI failures are known issues

@JeffBezanson JeffBezanson merged commit 0810648 into master Mar 28, 2017
@tkelman tkelman deleted the jb/precompilemore branch March 28, 2017 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:precompilation Precompilation of modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants