Re: [fpc-pascal] Improved FPC JSON-RPC support
On Wed, 29 Dec 2021, Graeme Geldenhuys via fpc-pascal wrote: On 2021-12-29 09:54, Michael Van Canneyt via fpc-pascal wrote: They showed clearly that the used protocol (http & xml) is the largest factor. in 2013 I did many tests in a JSON REST framework: the times for streaming were dwarfed by the time spent on network & database access. Have you, or anybody else, ever done some benchmarks to see how "expensive" in CPU time it is to parse the exact same data in XML format vs JSON format? I couldn't find FPC specific benchmarks, but did a basic Firefox v95.0.2 browser Network tests (with caching disabled). A 54KB JSON file vs a 121KB XML file, which represents the exact same 1000 rows of a database table. Interestingly (and surprising to me), Firefox managed to load the XML in about half the time (172ms) compared to the JSON (386ms) file. I did the load test multiple times, and the results were consistent. It depends on how you load it. It's quite possible the XML uses a SAX model where the nodes are not loaded till you actually access them. So I would definitely also add a loop that runs over all rows. I did a test once on pure FPC, and there the JSON worked faster. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Improved FPC JSON-RPC support
On 2021-12-29 13:56, Graeme Geldenhuys via fpc-pascal wrote: I did the load test multiple times, and the results were consistent. It should go without saying, my testing methodology could be flawed. ;-) G. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Improved FPC JSON-RPC support
On 2021-12-29 09:54, Michael Van Canneyt via fpc-pascal wrote: They showed clearly that the used protocol (http & xml) is the largest factor. in 2013 I did many tests in a JSON REST framework: the times for streaming were dwarfed by the time spent on network & database access. Have you, or anybody else, ever done some benchmarks to see how "expensive" in CPU time it is to parse the exact same data in XML format vs JSON format? I couldn't find FPC specific benchmarks, but did a basic Firefox v95.0.2 browser Network tests (with caching disabled). A 54KB JSON file vs a 121KB XML file, which represents the exact same 1000 rows of a database table. Interestingly (and surprising to me), Firefox managed to load the XML in about half the time (172ms) compared to the JSON (386ms) file. I did the load test multiple times, and the results were consistent. Regards, Graeme ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Improved FPC JSON-RPC support
On 12/29/21 6:29 AM, Graeme Geldenhuys via fpc-pascal wrote: On 2021-12-29 11:22, wkitty42--- via fpc-pascal wrote: i'm sorry... what is WST? googling https://wiki.lazarus.freepascal.org/Web_Service_Toolkit thank you! :) -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list where it belongs!* ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Improved FPC JSON-RPC support
On 2021-12-29 11:22, wkitty42--- via fpc-pascal wrote: i'm sorry... what is WST? googling https://wiki.lazarus.freepascal.org/Web_Service_Toolkit G. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Improved FPC JSON-RPC support
On 29/12/2021 11:22, wkitty42--- via fpc-pascal wrote: On 12/29/21 4:54 AM, Michael Van Canneyt via fpc-pascal wrote: Translated to RPC: if you want speed, don't use HTTP or JSON. WST offers a binary protocol and plain TCP channel, it's bound to be much faster. i'm sorry... what is WST? googling for "wst binary protocol tcp ip channel" doesn't turn up anything informative for me and acronym searching is equally uninformative... getting old sucks :? WST stands for Web Services Toolkit, a package that offers both provision (authoring) of web services, and facilitates programming web service consumption. A package for the framework is available in Lazarus' online package manager. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Improved FPC JSON-RPC support
On Wed, 29 Dec 2021, wkitty42--- via fpc-pascal wrote: On 12/29/21 4:54 AM, Michael Van Canneyt via fpc-pascal wrote: Translated to RPC: if you want speed, don't use HTTP or JSON. WST offers a binary protocol and plain TCP channel, it's bound to be much faster. i'm sorry... what is WST? googling for "wst binary protocol tcp ip channel" doesn't turn up anything informative for me and acronym searching is equally uninformative... getting old sucks :? Web Service Toolkit: https://wiki.freepascal.org/Web_Service_Toolkit The Lazarus online package manager can install it. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Improved FPC JSON-RPC support
Am 29.12.2021 um 12:22 schrieb wkitty42--- via fpc-pascal: On 12/29/21 4:54 AM, Michael Van Canneyt via fpc-pascal wrote: Translated to RPC: if you want speed, don't use HTTP or JSON. WST offers a binary protocol and plain TCP channel, it's bound to be much faster. i'm sorry... what is WST? googling for "wst binary protocol tcp ip channel" doesn't turn up anything informative for me and acronym searching is equally uninformative... getting old sucks :? WST = Web Service Toolkit https://wiki.freepascal.org/Web_Service_Toolkit Regards, Sven ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Improved FPC JSON-RPC support
On 12/29/21 4:54 AM, Michael Van Canneyt via fpc-pascal wrote: Translated to RPC: if you want speed, don't use HTTP or JSON. WST offers a binary protocol and plain TCP channel, it's bound to be much faster. i'm sorry... what is WST? googling for "wst binary protocol tcp ip channel" doesn't turn up anything informative for me and acronym searching is equally uninformative... getting old sucks :? -- NOTE: No off-list assistance is given without prior approval. *Please keep mailing list traffic on the list where it belongs!* ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Improved FPC JSON-RPC support
On Tue, 28 Dec 2021, Don Duvall via fpc-pascal wrote: Has any performance tests been ran, to see what the runtime impact of utilizing RTTI is? Hopefully negligent in the grand scheme... No tests have been run. I also don't know what exactly you would compare it with ? Using some plain common sense: The 'older' json-rpc mechanism relied on TJSONRPCHandler components on a Datamodule. Loading a datamodule and all components (one per exposed method) on it also uses RTTI, but is bound to beslower due to all the loading & parsing of the lfm file for every call. Even so, all that will be dwarfed by the network latency & http+json protocol: Many years ago, I did a speed comparison test of the various protocols offered by Remobjects SDK in delphi. It was published in Toolbox magazine: https://www.freepascal.org/~michael/articles/index.html#remobjects2 (the date on the article is misleading, it is actually older, must have been 2005 or so) They showed clearly that the used protocol (http & xml) is the largest factor. in 2013 I did many tests in a JSON REST framework: the times for streaming were dwarfed by the time spent on network & database access. Translated to RPC: if you want speed, don't use HTTP or JSON. WST offers a binary protocol and plain TCP channel, it's bound to be much faster. Michael. Thanks, Don On 12/28/2021 2:11 PM, Michael Van Canneyt via fpc-pascal wrote: On Tue, 28 Dec 2021, Graeme Geldenhuys via fpc-pascal wrote: On 2021-12-28 15:25, Michael Van Canneyt via fpc-pascal wrote: Thanks to the magic of RTTI and Invoke(), creating a JSON-RPC server has just become significantly easier ! That's pretty neat - nicely done Michael. We do our best. // Create a class that implements the interface Type TIntf2Impl = class(TInterfacedObject, IMyOtherInterface) public function Echo(args: TStringArray): String; function SayHello: string; end; ...snip... // Register the class using an interface factory: Function GetMyOtherInterface(Const aName : string) : IInterface; begin Result:=TIntf2Impl.Create as IInterface; end; Slightly off topic, and my Object Pascal is getting a bit rusty as the years go by. ;-) In your factory above, is the "as IInterface" part needed. Can't the FPC compiler automatically cast the return type based on the function return type, and the fact that the compiler should know that TIntf2Impl type implements TInterfacedObject? No, theoretically it probably could, but type inference is not implemented in Pascal. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Improved FPC JSON-RPC support
Has any performance tests been ran, to see what the runtime impact of utilizing RTTI is? Hopefully negligent in the grand scheme... Thanks, Don On 12/28/2021 2:11 PM, Michael Van Canneyt via fpc-pascal wrote: On Tue, 28 Dec 2021, Graeme Geldenhuys via fpc-pascal wrote: On 2021-12-28 15:25, Michael Van Canneyt via fpc-pascal wrote: Thanks to the magic of RTTI and Invoke(), creating a JSON-RPC server has just become significantly easier ! That's pretty neat - nicely done Michael. We do our best. // Create a class that implements the interface Type TIntf2Impl = class(TInterfacedObject, IMyOtherInterface) public function Echo(args: TStringArray): String; function SayHello: string; end; ...snip... // Register the class using an interface factory: Function GetMyOtherInterface(Const aName : string) : IInterface; begin Result:=TIntf2Impl.Create as IInterface; end; Slightly off topic, and my Object Pascal is getting a bit rusty as the years go by. ;-) In your factory above, is the "as IInterface" part needed. Can't the FPC compiler automatically cast the return type based on the function return type, and the fact that the compiler should know that TIntf2Impl type implements TInterfacedObject? No, theoretically it probably could, but type inference is not implemented in Pascal. Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Improved FPC JSON-RPC support
On Tue, 28 Dec 2021 23:11:42 +0100 (CET) Michael Van Canneyt via fpc-pascal wrote: >[...] > > Slightly off topic, and my Object Pascal is getting a bit rusty as > > the years go by. ;-) In your factory above, is the "as > > IInterface" part needed. No. > Can't the FPC compiler automatically cast > > the return type based on the function return type, and the fact > > that the compiler should know that TIntf2Impl type implements > > TInterfacedObject? Yes. > No, theoretically it probably could, but type inference is not > implemented in Pascal. This is not type inference. It compiles with fpc and pas2js: Function GetMyOtherInterface(Const aName : string) : IInterface; begin Result:=TIntf2Impl.Create; end; Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Improved FPC JSON-RPC support
On Tue, 28 Dec 2021, Graeme Geldenhuys via fpc-pascal wrote: On 2021-12-28 15:25, Michael Van Canneyt via fpc-pascal wrote: Thanks to the magic of RTTI and Invoke(), creating a JSON-RPC server has just become significantly easier ! That's pretty neat - nicely done Michael. We do our best. // Create a class that implements the interface Type TIntf2Impl = class(TInterfacedObject, IMyOtherInterface) public function Echo(args: TStringArray): String; function SayHello: string; end; ...snip... // Register the class using an interface factory: Function GetMyOtherInterface(Const aName : string) : IInterface; begin Result:=TIntf2Impl.Create as IInterface; end; Slightly off topic, and my Object Pascal is getting a bit rusty as the years go by. ;-) In your factory above, is the "as IInterface" part needed. Can't the FPC compiler automatically cast the return type based on the function return type, and the fact that the compiler should know that TIntf2Impl type implements TInterfacedObject? No, theoretically it probably could, but type inference is not implemented in Pascal. Michael.___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Improved FPC JSON-RPC support
On 2021-12-28 15:25, Michael Van Canneyt via fpc-pascal wrote: Thanks to the magic of RTTI and Invoke(), creating a JSON-RPC server has just become significantly easier ! That's pretty neat - nicely done Michael. // Create a class that implements the interface Type TIntf2Impl = class(TInterfacedObject, IMyOtherInterface) public function Echo(args: TStringArray): String; function SayHello: string; end; ...snip... // Register the class using an interface factory: Function GetMyOtherInterface(Const aName : string) : IInterface; begin Result:=TIntf2Impl.Create as IInterface; end; Slightly off topic, and my Object Pascal is getting a bit rusty as the years go by. ;-) In your factory above, is the "as IInterface" part needed. Can't the FPC compiler automatically cast the return type based on the function return type, and the fact that the compiler should know that TIntf2Impl type implements TInterfacedObject? Regards, Graeme ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal