Skip to content

Does wangle have official benchmark data? #20

Open

Description

@billowqiu

I modify the telnet example to echo protocol.

/*
 *  Copyright (c) 2015, Facebook, Inc.
 *  All rights reserved.
 *
 *  This source code is licensed under the BSD-style license found in the
 *  LICENSE file in the root directory of this source tree. An additional grant
 *  of patent rights can be found in the PATENTS file in the same directory.
 *
 */

#include <gflags/gflags.h>

#include <wangle/bootstrap/ServerBootstrap.h>
#include <wangle/channel/AsyncSocketHandler.h>
#include <wangle/codec/LineBasedFrameDecoder.h>
#include <wangle/codec/FixedLengthFrameDecoder.h>
#include <wangle/codec/StringCodec.h>

using namespace folly;
using namespace wangle;

DEFINE_int32(port, 8096, "echo server port");
DEFINE_int32(frame_length, 10, "echo frame length");

typedef Pipeline<IOBufQueue&, std::string> EchoPipeline;

class EchoHandler : public HandlerAdapter<std::string> {
 public:
  virtual void read(Context* ctx, std::string msg) override {
    if (msg.empty()) 
    {
      write(ctx, "Please type something.\r\n");
    } 
    else if (msg == "bye") 
    {
      write(ctx, "Have a fabulous day!\r\n").then([ctx, this]{
        close(ctx);
      });
    } 
    else 
    {
      write(ctx,  msg);
    }
  }

  virtual void transportActive(Context* ctx) override {
    auto sock = ctx->getTransport();
    SocketAddress localAddress;
    sock->getLocalAddress(&localAddress);
    //write(ctx, "Welcome to " + localAddress.describe() + "!\r\n");
    std::cout << "Welcome to " + localAddress.describe() + "!\r\n" << std::endl;
    //write(ctx, "Type 'bye' to disconnect.\r\n");
  }
};

class EchoPipelineFactory : public PipelineFactory<EchoPipeline> {
 public:
  EchoPipeline::Ptr newPipeline(std::shared_ptr<AsyncTransportWrapper> sock) {
    auto pipeline = EchoPipeline::create();
    pipeline->addBack(AsyncSocketHandler(sock));
    pipeline->addBack(FixedLengthFrameDecoder(FLAGS_frame_length));
    pipeline->addBack(StringCodec());
    pipeline->addBack(EchoHandler());
    pipeline->finalize();

    return pipeline;
  }
};

int main(int argc, char** argv) {
  google::ParseCommandLineFlags(&argc, &argv, true);

  ServerBootstrap<EchoPipeline> server;
  server.childPipeline(std::make_shared<EchoPipelineFactory>());
  server.bind(FLAGS_port);
  server.waitForStop();

  return 0;
}

I test it use my echoclient with 10 bytes playload,then the qps is only 13w。
My hardware:
model name : Intel(R) Xeon(R) CPU E5-2450 v2 @ 2.50GHz
cpu MHz : 2500.000
cache size : 20480 KB
MemTotal: 132133772 kB
OS:
CentOS release 6.3 (Final) with gcc 4.8

Activity

  1. djwatson commented on Dec 22, 2015

    @djwatson

    The qps is only 13? I'm not sure I quite follow.

    No, we don't have an official benchmark.

    Accepts will be limited by the kernel lock limit (even with SO_REUSEPORT).
    For raw throughput on small frames, Proxygen gets ~20k / s, fbthrift gets upwards of 500k/s with pipelining turned up. More if you start disabling some of the stats features.

  2. billowqiu commented on Dec 23, 2015

    @billowqiu
    Author

    Qps is not only 13,but 130k/s, its mine fault.
    Accepts hasn't problem.
    But i use the same client with libeven,its qps can get 400k/s

  3. ghost added a commit that references this issue on Aug 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions