Re: c++ web scripting

From: Shailesh Humbad (noreply_at_nowhere.com)
Date: 09/13/04


Date: Mon, 13 Sep 2004 14:22:19 GMT

Phlip wrote:
> Okay, this is a non-sequitur. Here's how C++ works. You write a
program, run
> a compiler, produce an executable, put it on a server, and stroll away. The
> executable never changes. It may frequently serve similar pages with
> different content. There's never a need to recompile it (regardless what
> page content it serves).
>
> When you say "cached", this makes me think you think C++ must recompile each
> time it is used, or each time the data changes, or something. If you
> envision some slight performance boost from serving the same page twice
> without re-rendering it, then you are confusing some other CGI optimization
> system with C++ compilation. If you need such a performance boost, just save
> your page an re-serve it.
>
> Please tell a complete, round-trip story that you envision some hypothetical
> C++ CGI layer doing.
>

Yeah, I can see where the confusion lies. When I say cached, I mean
the executables themselves are cached, not the HTML output of those
executables. Here is the algorithm:

(In Web Server)
* Web server receives request for a .cpp file.
* Web server invokes the CGI handler for .cpp files, ServeCPPFile.
(In ServeCPPFile)
If file does not exist Then
    Delete any file status entry from the database
    Return 404
End If
* Lookup FileLastModifiedTime in database, searching by file name.
If no file status exist in the database Then
    Save the FileName and LastModified timestamp in the database
    Compile the cpp code (save exe in cache folder)
Else
       If actual FileLastModified != FileLastModified in database Then
          Compile the cpp code (save exe in cache folder)
       End If
End If
* Run the compiled code
(In Web Server)
* Output of ServeCPPFile is sent to the client.

It's easiest to think of the C++ CGI Layer as spawning/forking a new
process to handle each page request. In this case, the ServeCPPFile
process is launched, and then ServeCPPFile launches another process to
run the compiled CPP code. In practice, some other techniques might
be used to save the overhead of creating processes.

Process heirarchy:
Apache -> ServeCPPFile -> EXE File

Output piping:
Client <- Apache <- ServeCPPFile <- EXE File

>
> No religion needed. If you pipe data, whatever its format, into XML, it will
> become compatible with a very good template system, XSLT, which has a
> built-in mode to emit XHTML.
>
> Further, you can detect the user's browser type, and if it is compatible,
> you can send it your XSLT, and it will render the pages for you. All you
> need to do is send that browser your XML payload, and it does the rest.
> That's not religion, it is interoperability. We could have got it with
> tab-delimited files, or INI file format, or whatever. As an accident of
> history, we got it with XML.
>

I'm not familiar with XSLT's advantages, having never tried it, but
I'll take your word for it. One caveat is that one loses some
performance for the gain in interoperability, particularly for legacy
data in databases.



Relevant Pages

  • Re: 64-bit memory consumption
    ... because of GC memory compaction, ... *improved* over manual allocation. ... Well, this doesn't really have to be expected, 'old' compiler technology ... server, your cache is shared by multiple applications, and you can't ...
    (borland.public.delphi.non-technical)
  • Re: Need help with threading..
    ... the threads in the thread pool are part of the MTA apartment. ... This might not work with your out of process COM server. ... MyKindOfObject myObject = new MyKindOfObject; ... You said that they are COM executables which honestly, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Decline and fall of scripting languages ?
    ... > believe that all OCaml versions "crush" all Erlang versions in performance. ... looking a little more at the docs of the languages (haven't written ... typed and has apparently has a real compiler, ... > I'd suggest finding that Erlang web server writeup. ...
    (comp.lang.python)
  • Re: Reducing the size of executables produced by GNAT
    ... 120K or 45K or 10K CGI executables won't make a difference because the ... The Ada Web Server library from AdaCore was designed ... I do not know how to do with the exceptions runtime. ...
    (comp.lang.ada)
  • Re: How do I find where my application is crashing
    ... obvious when compiled as a Release build because of optimizations and ... Try reducing the compiler and linker optimization settings 1 by 1 ... > simply crashing but with no signs/details on where the crash is occuring. ... > server is running on a Win2K3 host. ...
    (microsoft.public.dotnet.general)