squeaky-pl / japronto

Screaming-fast Python 3.5+ HTTP toolkit integrated with pipelining HTTP server based on uvloop and picohttpparser.
MIT License
8.61k stars 581 forks source link

CPU hits illegal instruction signal on older hardware #39

Closed hashgupta closed 7 years ago

hashgupta commented 7 years ago

I installed Japronto on OSX via setup.py, and attempted to run the hello world example. The example threw an error when I tried to connect to it via my browser or wrk. The error message was

Worker exited with code -4!

Note: I am using a 2010 Macbook pro with Sierra, and received this error straight from the fresh git clone. The installation ran fine but I received a few warnings about uvloop.

wku commented 7 years ago

a similar error, ubuntu 16.04 all required libraries are updated Worker exited with code -4!

squeaky-pl commented 7 years ago

OK, signal 4 means illegal instruction (CPU encountered an instruction that it doesnt know). Is it possible that your computer doesnt have SSE 4.2 extensions. What is your CPU model?

@Superman132 I think the first Macbook to support SSE 4.2 is from 2011 @wku can you provide cat /proc/cpuinfo

This should be fixed, the plan:

squeaky-pl commented 7 years ago

@Superman132, @wku I tried to address the problem. Can you try the version from this pull request? https://github.com/squeaky-pl/japronto/pull/40

Be sure that you removed previous version and checked out right branch in git (sse-fallback2)

hashgupta commented 7 years ago

After trying your branch, I experienced an error at installation python3 setup.py install yields the following error src/japronto/parser/cparser.c:747:5: error: use of unknown builtin '__builtin_cpu_init' [-Wimplicit-function-declaration] __builtin_cpu_init(); ^ 1 error generated. error: command 'clang' failed with exit status 1'

squeaky-pl commented 7 years ago

@Superman132 yes, I need to find a clang counterpart of that functionality. A clang expert on the team would help.

squeaky-pl commented 7 years ago

@Superman132 I updated the code to include a clang version, can you pull again and retry?

wku commented 7 years ago

AMD Phenom(tm) II X6 1055T Processor cpuinfo.txt

squeaky-pl commented 7 years ago

@wku Yes, that CPU is missing SSE 4.2 extensions. @wku can you try uninstalling the version you have and try with:

pip3 install git+git://github.com/squeaky-pl/japronto.git@sse-fallback2
wku commented 7 years ago

Yes, this version works, and issues a warning thank

Warning: Host CPU doesnt support SSE 4.2, selecting slower implementationAccepting connections

wku commented 7 years ago

wrk -c 100 -t 6 -d 60 http://localhost:8080 Running 1m test @ http://localhost:8080 6 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 765.45us 1.38ms 40.23ms 91.54% Req/Sec 36.21k 8.52k 70.99k 58.00% 12982360 requests in 1.00m, 1.11GB read Requests/sec: 216022.62 Transfer/sec: 18.95MB

update.. wrk -t 6 -c 100 -d 2 -s misc/pipeline.lua http://localhost:8080 Running 2s test @ http://localhost:8080 6 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 3.62ms 3.76ms 45.02ms 87.57% Req/Sec 88.12k 18.30k 127.22k 71.67% 1056720 requests in 2.02s, 92.71MB read Requests/sec: 523440.70 Transfer/sec: 45.93MB

squeaky-pl commented 7 years ago

@wku that's not bad at all for a non-pipelined benchmark. Close to what you can do on a modern Intel i7 processor with SSE 4.2.

wku commented 7 years ago

yes I agree, OK

hashgupta commented 7 years ago

Sorry about keeping this thread alive, but I just tried the sse-fallback2 branch and tried to install via clang.

It gave the following error src/japronto/cpu_features.c:11:16: error: use of undeclared identifier 'bit_SSE4_2' return ecx & bit_SSE4_2; ^ 1 error generated. This same error occurred on master branch also.

squeaky-pl commented 7 years ago

@Superman123 thanks for trying this out. This is another difference between clang and gcc. I think I finally got it right and upcoming 0.1.1 should work.

squeaky-pl commented 7 years ago

@Superman123 0.1.1 is out, please pip install japronto. It should get you a warning about missing SSE 4.2 but continue working.

hashgupta commented 7 years ago

Thanks everyone, The latest japronto release seemed to work as expected on my MacBook. I am closing this issue.