Skip to content

Commit bf880a7

Browse files
author
greensheng
committed
perf
1 parent bd7efea commit bf880a7

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

matching/engine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func (e *Engine) runSnapshots() {
221221

222222
for {
223223
select {
224-
case <-time.After(10 * time.Second):
224+
case <-time.After(30 * time.Second):
225225
// make a new snapshot request
226226
e.snapshotReqCh <- &Snapshot{
227227
OrderOffset: orderOffset,

matching/order_book.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,19 +65,6 @@ type orderBookSnapshot struct {
6565
OrderIdWindow Window
6666
}
6767

68-
type depth struct {
69-
// 保存所有正在book上的order
70-
orders map[int64]*BookOrder
71-
72-
// 价格优先的priceLevel队列,用于获取level2
73-
// Price -> *PriceLevel
74-
levels *treemap.Map
75-
76-
// 价格优先,时间优先的订单队列,用于订单match
77-
// priceOrderIdKey -> orderId
78-
queue *treemap.Map
79-
}
80-
8168
type PriceLevel struct {
8269
Price decimal.Decimal
8370
Size decimal.Decimal
@@ -341,6 +328,19 @@ func (o *orderBook) nextTradeSeq() int64 {
341328
return o.tradeSeq
342329
}
343330

331+
type depth struct {
332+
// 保存所有正在book上的order
333+
orders map[int64]*BookOrder
334+
335+
// 价格优先的priceLevel队列,用于获取level2
336+
// Price -> *PriceLevel
337+
levels *treemap.Map
338+
339+
// 价格优先,时间优先的订单队列,用于订单match
340+
// priceOrderIdKey -> orderId
341+
queue *treemap.Map
342+
}
343+
344344
func (d *depth) add(order BookOrder) {
345345
d.orders[order.OrderId] = &order
346346

pushing/level2_stream.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (s *OrderBookStream) runApplier() {
122122
s.snapshotCh <- lastLevel2Snapshot
123123
}
124124

125-
if lastFullSnapshot == nil || s.orderBook.seq-lastFullSnapshot.Seq > 1000 {
125+
if lastFullSnapshot == nil || s.orderBook.seq-lastFullSnapshot.Seq > 10000 {
126126
lastFullSnapshot = s.orderBook.SnapshotFull()
127127
s.snapshotCh <- lastFullSnapshot
128128
}

0 commit comments

Comments
 (0)