Redesign of dlang.org

Sönke Ludwig via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 10 01:12:53 PDT 2014


Am 10.06.2014 02:18, schrieb w0rp:
> I have updated the site and the repository with all of the D changelogs
> split into their own pages. I had to reformat a few things, primarily
> example code, so it would fit nicely in smaller column sizes. I marked
> sections with headings so it fits into a table of contents. One major
> thing that's missing is syntax highlighting, as I'm not sure what to use
> for that.
>
> http://w0rp.com:8010/changelog
>
> Here is what I've noticed so far that's good about the diet templates.
>
> 1. The template syntax, taken from Jade, is easy to understand and clean.
> 2. I can do tricks like the table of contents easily.
>
> However, with the good comes the bad.
>
> 1. If you are recompiling one template, you are recompiling *all* of
> them. I'm getting closer to 100 templates, and it takes seconds to compile.

Sounds kind of like an ironic joke when viewed from a C++ background ;)

But yes, it's definitely not what you want to have for D. I'm not sure 
how much can be done about that, though - except from rewriting the CTFE 
engine with performance in mind (maybe even using a JIT compiler). Or 
maybe it's possible to be more liberal with algorithmic optimizations 
when the CTFE memory usage brought to a reasonable level.

> 2. Compiling many templates allocates like crazy during compile time and
> eats memory like a hog. It takes *5GB* of RAM to compile all of these
> templates.

Yes, which is why (at least with the current compiler front end) I'd 
strongly recommend to put long text content in a different format that 
is inserted at runtime (e.g. DDOC or Markdown).

>
> It seems like the vibe.d diet templates take heap allocation during
> compilation time way, way too far, to the point of them being
> impractical to use for large websites. Somewhere around 100 templates is
> something I would expect for a reasonably sized website.

It's not heap allocations. The problem is that during CTFE, currently 
basically every variable change allocates memory that is never freed 
again. I've used a few tricks to get the memory usage down (which is why 
the Diet compiler source code doesn't look very pretty), but basically 
the only way to get reasonable memory use is to fix the D front end.

>
> So I have a plea or two for vibe.d
>
> In addition to recompiling diet templates automatically during
> development, which has been mentioned before, I believe there should be
> an option to defer compilation of a template the first time, during
> development, until you view a page using it for the first time. This
> woud solve the slower compilation issue, because then you'd only pay for
> what you used.

That would probably even be a side-effect of the implementation of 
separately compiled templates (eagerly compiling them will require some 
additional code).

>
> Second, something must be done about memory allocation during
> compilation of diet templates. There's too much going on there.
>
> That's it for now.

See also https://issues.dlang.org/show_bug.cgi?id=6498


More information about the Digitalmars-d mailing list