Why is typing soooo long?

199 views
Skip to first unread message

Fabien Antoine

unread,
Feb 9, 2016, 11:21:19 AM2/9/16
to Haxe
Hi all,

I'm working on a nodejs project with all sources compiled with Haxe 3.2.1.
This project depends on latest hxnodejs and haxe-js-kit libraries among
some others.

Everything works correctly but the compilation always takes around 10 to
12 seconds while I only have 10 000 lines of code for my project.

If I run haxe with "--times" option I get the following report, and as
you can see, typing is the most time consuming part :

Total time : 10.010s
------------------------------------
analyzer-const-propagation : 0.040s, 0%
analyzer-local-dce : 0.010s, 0%
analyzer-simplify-apply : 0.000s, 0%
analyzer-simplify-unapply : 0.000s, 0%
analyzer-ssa-apply : 0.040s, 0%
analyzer-ssa-unapply : 0.000s, 0%
filters : 0.100s, 1%
generate js : 0.050s, 0%
haxelib : 0.000s, 0%
macro execution : 2.240s, 22%
other : 1.750s, 17%
parsing : 0.190s, 2%
typing : 5.590s, 56%

I don't know if this "delay" is normal for a project of this size ?


I know about haxe compilation server but I can't find any good editor to
run it easily on OS X.
I tried Atom, VSCode and SublimeText but they don't seem to run the
compilation server.

Do you have any idea why it takes so much time and if I could improve it ?

Thanks

Dion Whitehead Amago

unread,
Feb 9, 2016, 2:44:03 PM2/9/16
to Haxe
I'm pretty sure Sublime Text runs the compilation server by default.

Are you running a lot of macros? That's usually the piece that takes the longest when I'm compiling Haxe->JS for Node.js

Philippe Elsass

unread,
Feb 9, 2016, 3:35:07 PM2/9/16
to Haxe
How long does it take without the analyser? (it seems you have -D analyzer)

It doesn't seem normal really, I have a work project on an ultrabook generating a >2Mb JS including over 1k classes with a similar macro run time (quite a bit of macros there) but only 1.6s typing, and without completion server.

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.



--
Philippe

Nicolas Cannasse

unread,
Feb 9, 2016, 4:30:20 PM2/9/16
to haxe...@googlegroups.com
Le 09/02/2016 20:44, Dion Whitehead Amago a écrit :
> I'm pretty sure Sublime Text runs the compilation server by default.
>
> Are you running a lot of macros? That's usually the piece that takes the
> longest when I'm compiling Haxe->JS for Node.js

Compilation server is disabled or you would get a time measure for
"module cache check"

Best,
Nicolas

Fabien Antoine

unread,
Feb 10, 2016, 1:27:56 AM2/10/16
to haxe...@googlegroups.com

Le 09/02/2016 21:34, Philippe Elsass a écrit :
> How long does it take without the analyser? (it seems you have -D
> analyzer)
>
> It doesn't seem normal really, I have a work project on
> an ultrabook generating a >2Mb JS including over 1k classes with a
> similar macro run time (quite a bit of macros there) but only 1.6s
> typing, and without completion server.
>

If I run without the analyzer I get a small improvement but only if I
run haxe by hand :

Total time : 9.550s
------------------------------------
filters : 0.110s, 1%
generate js : 0.040s, 0%
haxelib : 0.000s, 0%
macro execution : 2.090s, 22%
other : 1.680s, 18%
parsing : 0.200s, 2%
typing : 5.430s, 57%


If I run it from Sublime it does nothing:

Total time : 12.440s
------------------------------------
filters : 0.060s, 0%
generate js : 0.050s, 0%
haxelib : 0.000s, 0%
macro execution : 2.380s, 19%
other : 1.780s, 14%
parsing : 0.210s, 2%
typing : 7.960s, 64%

Fabien Antoine

unread,
Feb 10, 2016, 1:33:32 AM2/10/16
to haxe...@googlegroups.com
I have some macros related to my own project and some others from
external libraries (tink, js-kit,...) but nothing too expensive I think.
I tried to remove my own macros and it didn't change anything.


And I can confirm than by default it doesn't use the compilation server.
It does start one but I need to add "--connect 6001" to my build.hxml to
be able to use it.

Fabien Antoine

unread,
Feb 10, 2016, 2:19:49 AM2/10/16
to Haxe
The other bad thing is even if I try to work with the compilation server I get the following error unless I restart it:

/usr/local/lib/haxe/std/StdTypes.hx:119: characters 7-35 : Duplicate metadata 'interface'

Philippe Elsass

unread,
Feb 10, 2016, 4:38:25 AM2/10/16
to Haxe
I wonder if it might be worth getting someone from the compiler team to give this a look. This clearly looks abnormal...

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.



--
Philippe

Fabien Antoine

unread,
Feb 10, 2016, 8:20:29 AM2/10/16
to haxe...@googlegroups.com
I'd be glad to share more informations with someone from the compiler team if it can help.

Nicolas Cannasse

unread,
Feb 10, 2016, 10:53:02 AM2/10/16
to haxe...@googlegroups.com
Le 10/02/2016 14:20, Fabien Antoine a écrit :
> I'd be glad to share more informations with someone from the compiler
> team if it can help.

I have no idea where this error could come from. Maybe from one of your
macros ?

Please post an issue here: https://github.com/HaxeFoundation/haxe

Also, please make sure to try with Haxe nightly first.

Best,
Nicolas

Fabien Antoine

unread,
Feb 10, 2016, 11:28:37 AM2/10/16
to haxe...@googlegroups.com
Le 10/02/2016 16:52, Nicolas Cannasse a écrit :
I have no idea where this error could come from. Maybe from one of your macros ?

Please post an issue here: https://github.com/HaxeFoundation/haxe

Also, please make sure to try with Haxe nightly first.

Best,
Nicolas

I tried with latest nightly build (Haxe Compiler 3.3.0 (git build development @ 3d001e0)) and got same results:

Total time : 12.090s
------------------------------------
  analyzer-cleanup : 0.000s, 0%
  analyzer-filter-apply : 0.000s, 0%
  analyzer-from-texpr : 0.040s, 0%
  analyzer-fusion : 0.010s, 0%
  analyzer-to-texpr : 0.010s, 0%
  filters : 0.090s, 1%
  generate js : 0.060s, 0%
  haxelib : 0.000s, 0%
  macro execution : 2.770s, 23%
  other : 1.490s, 12%
  parsing : 0.310s, 3%
  typing : 7.310s, 60%


Is it possible to get a more detailed timing result? Maybe I'll be able to track down the reason more easily...
I'd like to see a kind of @:macroStats meta to get the detail of a macro run (timing, number of calls,...).

I also noticed than the analyzer still run while I disabled it on my hxml file. Is it enabled by default in 3.3.0?


Anyway, I'll create an issue for this but I thinks it's hardly reproducible without the whole project.

Ben Merckx

unread,
Feb 10, 2016, 2:17:42 PM2/10/16
to Haxe
Compiling with -D macro-times should give you more info on macro runtime when used with --times
Reply all
Reply to author
Forward
0 new messages