Recent

Author Topic: fphttp slower with threads  (Read 1014 times)

Trenatos

  • Sr. Member
  • ****
  • Posts: 454
  • Software developer - Open source contributor
    • MarcusFernstrom.com
fphttp slower with threads
« on: February 28, 2018, 04:14:38 pm »
I'm playing with fphttp to create an API and comparing it to my usual stack of OpenBD (CFML engine running on the JVM), I also have a simple Java Spring API to compare with.

I'm comparing them locally with WRK2 using
Code: Pascal  [Select]
  1. wrk2 -t2 -c100 -d30s -R2000 --latency http://localhost:7080/status/

In the process I've done both x86 and x64 with and without threads and had some odd results.

Both architectures have about 13% less throughput when setting multithreading to true, and the x64 is a tad slower than the x86 version, but only by a little.

Compared to my usual stack both have about 26% less throughput.

I'm surprised that they're slower than the Java versions at all, that's a big disappointment as I was hoping for better performance with a native binary solution compared to Java, and I'm surprised that threading caused a drop in throughput.

I ran each test a good handful of times and the average I got was:
OpenBD - 1995 requests/sec
Java Spring API - 1997 requests/sec

FPC fphttp
No threading
x86 - 1560 requests/sec
x64 - 1450 requests/sec

FPC fphttp
With threading
x86 - 1480 requests/sec
x64 - 1370 requests/sec

Tested on my Macbook Pro.
« Last Edit: March 01, 2018, 04:12:02 pm by Trenatos »

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6619
Re: fphttp slower with threads
« Reply #1 on: February 28, 2018, 04:32:28 pm »
What does the Mac Brook  pro run?   Afaik OS X has several threading APIs,  (POSIX and native?), maybe it is merely a result of which API you pick.

Trenatos

  • Sr. Member
  • ****
  • Posts: 454
  • Software developer - Open source contributor
    • MarcusFernstrom.com
Re: fphttp slower with threads
« Reply #2 on: February 28, 2018, 04:58:22 pm »
It's running OSX El Capitan

System report:

Model Name: MacBook Pro
Model Identifier: MacBookPro11,5
Processor Name: Intel Core i7
Processor Speed: 2.5 GHz
Number of Processors: 1
Total Number of Cores: 4
L2 Cache (per Core): 256 KB
L3 Cache: 6 MB
Memory: 16 GB

I'm using these options in my fpc app
Code: Pascal  [Select]
  1. {$ifdef darwin}
  2. cthreads,
  3. cmem,
  4. {$endif}
« Last Edit: February 28, 2018, 06:02:42 pm by Trenatos »

Leledumbo

  • Hero Member
  • *****
  • Posts: 7983
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: fphttp slower with threads
« Reply #3 on: March 01, 2018, 06:51:20 pm »
It actually also happens on Linux, using cthreads, with both tested and tester programs running on the same machine. I have yet to compare using server to server setup, to avoid any intra resource sharing problem, but I suppose fpc would shine in such a setup.

Trenatos

  • Sr. Member
  • ****
  • Posts: 454
  • Software developer - Open source contributor
    • MarcusFernstrom.com
Re: fphttp slower with threads
« Reply #4 on: March 01, 2018, 07:22:39 pm »
I might give it a go under more proper server settings (Separate server instance from test machine, local network to avoid latency issues/spikes, etc.)

I'll come back with results of my tests when I get a setup going.