Git Product home page Git Product logo

xtp-marketdata's Introduction

XTP-MarketData

下载相关的 api 可以到中泰官网

需求

接收行情的回调函数需要以最快速度返回。

	///行情通知
	///@param market_data 行情数据,需要快速返回,否则会堵塞后续消息,当堵塞严重时,会触发断线
	virtual void OnMarketData(XTPMD *market_data) {}

主要思路

经查看指针地址可知, market_data 分配在栈上。因此不能直接在这里进行异步操作,因为不保证这个地址此后还能有效。
所以避免不开两个问题,一个是内存拷贝,一个是写文件。
为达到最快的存储速度,采用以下两个优化:

  1. 使用 Ringbuffer 存储
    避免每次接收到行情时进行内存分配。 参考内核的 kfifo 编写。
  2. 异步写文件
    io 操作是最费时的。必须异步进行。

优化

  1. 线程池
    之前每次写文件,都需要创建一个线程,执行完毕后销毁。创建线程是一个较大的开销。
    于是使用一个线程池改进。目前只需要在线程池中开启一个线程即可。

xtp-marketdata's People

Contributors

double-free avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.