You are not logged in.
Pages: 1
We tried to make mORMot at the same time fast and safe, and able to scale with the best possible performance on the hardware it runs on. Multi-threading is the key to better usage of modern multi-core CPUs, and also client responsiveness.
As a result, on the Server side, our framework was designed to be thread-safe.
On typical production use, the mORMot HTTP server will run on its own optimized thread pool, then call the TSQLRestServer.URI method. This method is therefore expected to be thread-safe, e.g. from the TSQLHttpServer. Request method. Thanks to the RESTful approach of our framework, this method is the only one which is expected to be thread-safe, since it is the single entry point of the whole server. This KISS design ensure better test coverage.
Forum thread for Blog entry of http://blog.synopse.info/post/2013/09/1 … -of-mORMot
Offline
I found very interesting site http://www.techempower.com/benchmarks/
I think it's a good idea to participate (for framework popularization).
It seems we must be in top of list for Windows platform http://www.techempower.com/benchmarks/# … est=update
Offline
It seems we must be in top of list for Windows platform http://www.techempower.com/benchmarks/# … est=update
If I understand correctly the scope of this benchmark, and compare to our existing values, I suspect mORMot may perform quite well!
It should be easy to implement some sample applications matching the benchmark expectations at:
http://www.techempower.com/benchmarks/# … est=update
The C# source code available is pretty straightforward to me:
https://github.com/TechEmpower/Framewor … Program.cs
But it does not include ORM feature, just raw SQL - I'm quite confident our ORM will do wonders here.
The only missing feature is IMHO the HTML template.
We may hardcode it at first, adding some HTML escaping dedicated methods to our writer classes (or a dedicated XML/HTML class).
But we may give some code.
We did not make intensive test about MySQL/PostgreSQL, and it sounds like if this benchmark is using MySQL/PostgreSQL as backend, in addition to MongoDB.
Do you think it is possible to use SQLite3 at first? And/or simply rely on ZDBC connection, which is pretty good about reading.
I do not have much usage of Git nor GitHub, perhaps someone may help providing the pull requests?
What do you think?
Offline
In the "Test requirements" section exist remark about "If you have limited time, we recommend you start with the easiest tests (1 through 3)" - so we can participate without template. For HTML template I can add Mustache support. SpiderMonkey implementation not yet ready for including into mORMot, but this use-case I can implement......
I just test - not-optimized version give 1300 RPS for they template (w/o database support but using poor hardware (Core i5U). So I can implement section 4.
I think we can try to use sqlite3....
I also do not use git, so can't help in this part.
UPD.
Small optimization and I got 1750 RPS
Last edited by mpv (2013-09-12 19:05:42)
Offline
Another small optimization, and we got 19710 Request Per Second!
Result for command: > ab -c128 -n10000 -k http://localhost:888/m3/muchacha (run 10000 request 128 concurrent thread, keep-alive)
This is ApacheBench, Version 2.3 <$Revision: 1178079 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Server Software: Microsoft-HTTPAPI/2.0
Server Hostname: localhost
Server Port: 888
Document Path: /m3/muchacha
Document Length: 191 bytes
Concurrency Level: 128
Time taken for tests: 0.507 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Keep-Alive requests: 10000
Total transferred: 3940000 bytes
HTML transferred: 1910000 bytes
Requests per second: 19710.61 [#/sec] (mean)
Time per request: 6.494 [ms] (mean)
Time per request: 0.051 [ms] (mean, across all concurrent requests)
Transfer rate: 7583.96 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 1
Processing: 0 6 3.0 6 115
Waiting: 0 6 3.0 6 115
Total: 0 6 3.0 6 115
Test source ( this JS code evaluated into every mOROMot working thread )
mustache.js taken here: https://github.com/janl/mustache.js
var muchacha = (function(){
var
data = [{message: "hi!!!"}, {message: "lo!!"}];
var
tpl='<!DOCTYPE html>\
<html>\
<head><title>Fortunes</title></head>\
<body>\
<table>\
<tr><th>id</th><th>message</th></tr>\
{{#.}}\
<tr><td>{{id}}</td><td>{{message}}</td></tr>\
{{/.}}\
</table>\
</body>\
</html>';
var compiled = Mustache.compile(tpl);
return function(req, resp){
var output = compiled(data);
resp.writeEnd(output);
resp.writeHead('Content-type: text/html');
resp.statusCode = 200;
}
})();
Offline
Very nice!
What "optimization" are you talking about?
What is your test code?
BTW, what is the amount of memory and CPU used on the server side during the test, if you let it run for some time?
I'm wondering about SpiderMonkey text processing impact on memory and performances.
Can't wait for SpiderMonkey integration within mORMot...
Offline
"optimization" - Just optimize JS code (compile template first).
Max memory usage during 1 million request with 128 concurrency keep-alive connection is 120 Mb (initial 28 Mb - my server more thick compared to mORMot). I'm use manual garbage collection, so memory under full control.
Such performance is reached because of 2 thing:
1) Just In Time (JIT) compilation - actually after 2-nd run SpiderMonkey operate in ASM level.
2) Inside SpiderMonkey all objects organized in structure like your TRawUTF8ListHashed, so all property lookup operation is O(1).
Last edited by mpv (2013-09-13 10:57:02)
Offline
AB, I send you files for add SM support to mORMot. You cat put SynSM* as initial release into fossil repositiry.
In general - as for me is not a time to extend SM support more then in current implementation - we must wait for new stable SpiderMonkey version. As Mozilla sad: "The next release will be SpiderMonkey 24, around November 2013".
New SM24 API is very different from SM17 I currently use. Many thing become more simple. Debugger interface added, ES6 added (classes and types for variables). So my advice is to wait for SM24 release and when extend current implementation with RTTI support and simplify many things I don't like in current implementation.
But current implementation allow use SpiderMonkey 17 on low level...
Offline
This is great news!
We will take a look at your source code, and include it in the trunk version ASAP!
100% OK with the fact that SM24 will be a huge step forward: classes and typed variables will be a welcome enhancement, also for execution speed.
Thanks a lot!
Offline
"Typical results are the following:
Threads Clients/
thread Rows
inserted Total
Clients Time
(sec) Op/sec
1 1 10000 1 15.78 1267
50 1 10000 50 2.96 6737
100 1 10000 100 3.09 6462
100 1 20000 100 6.19 6459
50 2 100000 100 34.99 5714
100 2 100000 200 36.56 5469
500 100 100000 50000 92.92 2152"
Are you sure "15.78" seconds is correct for 1 thread 1 client?
Brent
Offline
Are you sure "15.78" seconds is correct for 1 thread 1 client?
AFAIK 10000/15.78 = 633.71 records write+read per second = 1267 HTTP requests per second.
This is in fact the network latency of the client-server access.
We are using a slow entreprise 100 MB local network with a hub, in this case, not a localhost test - which does not make much sense.
Very little CPU is used on both sides, in this case.
So it does make sense to me.
Offline
My colleague gave me access to good hardware (the same as here http://www.techempower.com/benchmarks/# … &test=json ). For request to timeStamp method I reach 180 000 response per second. For request to JavaScript method w/o database access - near 110 000 request per second. This is awesome!
Offline
That's it...
Code has been committed...
Introducing JavaScript execution using the SpiderMonkey library in mORMot framework!
See http://synopse.info/fossil/info/744111d689
Thanks a lot Pavel for all this GREAT contribution!
Now we can start integrating it officially within mORMot...
How could we do this in the most "KISS" way?
Offline
Could this be used to execute Javascript with Synapse HTTP components? Will it work with libraries such as JQuery, that is the question
Offline
I'm afraid you are making a little confusion.
AFAIK JQuery expected a DOM object tree to be available, not only a JavaScript.
IMHO there is no JQuery outside the web.
What you can do is something more like http://nodejs.org/
With the benefit of the mORMot core to be multithreaded, so potentially with much better performance than node.js.
You can use some part of JQuery within node.js - see http://stackoverflow.com/questions/1801 … th-node-js
But I suspect this is not what you want, and I doubt we will ever provide such a feature here, unless we provide compatibility with node.js API - which was envisaged but not yet planned.
Offline
Yes but AFAIK nodejs has DOM. And yes nodejs can run JQuery.
Last edited by louis_riviera (2013-09-23 17:24:26)
Offline
Yes but AFAIK nodejs has DOM.
Not nativly, you need third party source code of a node.js library.
See my answer just above.
What we are doing for instance is to use mustache JS library for HTML templates.
Works pretty well.
Or any other nice features like that.
Offline
Actually DOM can be used with this. https://github.com/tmpvar/jsdom
Or a better implementation https://github.com/MatthewMueller/cheerio
And this is the end result http://net.tutsplus.com/tutorials/javas … nd-jquery/
It is all possible Now you see that JQuery is INDEED used in server environment.
Last edited by louis_riviera (2013-09-23 17:41:48)
Offline
There is no DOM on the server level. DOM is browser-specific object passed to java script. Actually, browser implementation (fireFox or Chrome) pass to javaScript object named "window", and this object (written on C or C++) implement ALL method we usually call DOM ( getElementByID, querySelector and so on). jQuery is just helper build around "window" object. For example node.js (and our implementation) do not have "window" object, they have "global" object instead. Things you call "DOM in node.js" is just an emulation of DOM for only one reason - parse HTML downloaded from other sources. If someone really need to work with DOM on server level is better to use http://phantomjs.org/.
Offline
Yes but AFAIK you cannot control PhantomJS ..
Offline
Yes - we cannot control PhantomJS. I mean what if someone REALLY need to have DOM on the server PhantomJS is only one "real" server-side DOM implementation (the same codebase as in WebKit) - anything else is emulation. But IMHO DOM is not needed for server-side. DOM is a GIU. So it must be used only on cilent-side.
Offline
Also why bother with SpiderMonkey? If you can use BESEN. An ECMASCRIPT 5 full implementation in Pascal also cross platform.
No dll's are required.
Offline
Yes, we know about BESEN since years (just search this forum).
See http://synopse.info/forum/viewtopic.php?pid=6298#p6298
Why SpiderMonkey
I look at many engine before chose SpiderMonkey.
- pure Delphi Besen http://code.google.com/p/besen/ ( bad performance speed/memory compared to V8 & SM)
- V8 (C++ hard to integrate with Delphi)
- Microsoft scripting host ( COM / poor API / bad performance / only for Windows)
I choose SpiderMonkey because:
- Stability. It is the oldest, most heavily tuned engine available.
- Open source with HUGE community.
- C API – easy to integrate with Delphi
- ECMA-262 Edition 5 (and Harmony soon)
- It is very fast. Really VERY fast.
Offline
Well hopefully mpv can provide some examples on how to use it. Specifically how to add new functions etc.
Last edited by louis_riviera (2013-10-03 16:21:09)
Offline
I just add "/Samples/22-JavaScript HTTPApi web server"
Run sample, point browser to http://localhost:888/root/readme.md - response is MarkDown template rendered by SpiderMonkey.
DLL is here http://synopse.info/files/synsm.7z
Tested only for Delphi7 but hope it work with other versions.
AB - Sorry for commit comments - this is my first usage of fossil - I miss autosync is on.
Offline
Very nice indeed.
In project 22, can anyone suggest how to achieve auto direct user to login page from "root context"?
I mean if user types in browser-url "http://localhost:888/root", I would expect my login page to load (index.html).
Offline
Ok, it didn't work as expected, the referenced files inside index.html such as (.css, .js, etc.) are not processed, that is, not sent to client browser and the displayed page is incomplete.
If I set FileName := 'index.html' then Response.Content := is always index.html
Offline
in JSHttpApiServer.dpr line 169 add this code:
if (FileName = '') then FileName := 'index.html';
Thank you for replying.
Last edited by warleyalex (2013-10-16 20:00:55)
Offline
Where I can found mozjs64.dll ? In Delphi XE3 on Windows 7 Home Premium 64 bits, sample 22 raise an access violation:
First chance exception at $5A0DA137. Exception class $C0000005 with message 'access violation at 0x5a0da137: read of address 0x00004a78'. Process JSHttpApiServer.exe (3680).
Works with Delphi 7 in same machine.
Thanks.
Esteban
Offline
Unfortunately SM support not tested under x64. Current SynSM unit export SpiderMonkey 17 h files, so you can try to compile mozjs for x64 from sources http://ftp.mozilla.org/pub/mozilla.org/ … 0.0.tar.gz using this instruction https://developer.mozilla.org/en-US/doc … umentation. But this is huge work.....
Last edited by mpv (2013-11-28 20:44:06)
Offline
Thank you very much !!!
Esteban
Offline
Pages: 1