SlideShare una empresa de Scribd logo
1 de 26
The mechanism of
msgpack::unpacker
msgpack-c committer
Takatoshi Kondo
17/16/2014 Copyright OGIS-RI Co., Ltd.
Overview
Scenario 1
2
length
The length of the
“length” field is fixed size
length
msgpack msgpack msgpack msgpack
Scenario 2
Receiving a fixed length msgpack packets
msgpack packets with no length information (e.g. streaming)
msgpack msgpack msgpack msgpack
7/16/2014 Copyright OGIS-RI Co., Ltd.
Overview
Client
msgpack::unpacker
• Client receives msgpack data asynchronously.
• Data is separated as packets.
• The packet format is as follows:
length payload(msgpack format )
2. receive “length”
3.1. allocate length bytes memory
3.reserve_buffer(length)
unpacker may allocate more
than “length” bytes for
optimization.
1.create
4.buf = buffer()
msgpack::unpacked
7. unp = create
8.bRet = next(unp)
8.1. set unpacked contents
9.obj = get()
10.z = zone()
3
Scenario 1
7/16/2014 Copyright OGIS-RI Co., Ltd.
6.buffer_consumed(received)
5. reveived = receive payload into buf
Overview
Client
msgpack::unpacker
3.reserve_buffer(length)
1.create
4.buf = buffer()
msgpack::unpacked
7. unp = create
8.bRet = next(unp)
9.obj = get()
10.z = zone()
do application
processes using obj
and z
47/16/2014 Copyright OGIS-RI Co., Ltd.
• Client receives msgpack data asynchronously.
• Data is separated as packets.
• The packet format is as follows:
Scenario 1
length payload(msgpack format )
2. receive “length”
3.1. allocate length bytes memory
8.1. set unpacked contents
6.buffer_consumed(received)
5. reveived = receive payload into buf
Overview
Client
msgpack::unpacker
3.reserve_buffer(length)
1.create
4.buf = buffer()
msgpack::unpacked
7. unp = create
8.bRet = next(unp)
9.obj = get()
10.z = zone()
loop[bRet==true]
next() returns true while an
object is unpacked.
57/16/2014 Copyright OGIS-RI Co., Ltd.
• Client receives msgpack data asynchronously.
• Data is separated as packets.
• The packet format is as follows:
Scenario 1
length payload(msgpack format )
2. receive “length”
3.1. allocate length bytes memory
8.1. set unpacked contents
6.buffer_consumed(received)
5. reveived = receive payload into buf
loop[bRet==true]
Overview
Client
msgpack::unpacker
3.reserve_buffer(length)
1.create
4.buf = buffer()
6.buffer_consumed(received)
msgpack::unpacked
7. unp = create
8.bRet = next(unp)
9.obj = get()
10.z = zone()
loop
infinite loop for data receiving
67/16/2014 Copyright OGIS-RI Co., Ltd.
• Client receives msgpack data asynchronously.
• Data is separated as packets.
• The packet format is as follows:
Scenario 1
length payload(msgpack format )
2. receive “length”
3.1. allocate length bytes memory
5. reveived = receive payload into buf
8.1. set unpacked contents
loop
[total received
< length ]
loop[bRet==true]
Overview
Client
msgpack::unpacker
3.reserve_buffer(length)
1.create
4.buf = buffer()
msgpack::unpacked
7. unp = create
8.bRet = next(unp)
9.obj = get()
10.z = zone()
When payoads are received
intermittently, this loop is effective.
If msgpack object is incomplete and additional receive is
required, the return false.
The position of buf is advanced to
received size.
77/16/2014 Copyright OGIS-RI Co., Ltd.
• Client receives msgpack data asynchronously.
• Data is separated as packets.
• The packet format is as follows:
Scenario 1
length payload(msgpack format )
6.buffer_consumed(received)
2. receive “length”
3.1. allocate length bytes memory
5. reveived = receive payload into buf
8.1. set unpacked contents
loop
loop[bRet==true]
Overview
Client
msgpack::unpacker
3.reserve_buffer(length)
1.create
4.buf = buffer()
msgpack::unpacked
7. unp = create
8.bRet = next(unp)
9.obj = get()
10.z = zone()
8
The combination of each loop.
7/16/2014 Copyright OGIS-RI Co., Ltd.
• Client receives msgpack data asynchronously.
• Data is separated as packets.
• The packet format is as follows:
Scenario 1
length payload(msgpack format )
6.buffer_consumed(received)
2. receive “length”
3.1. allocate length bytes memory
5. reveived = receive payload into buf
8.1. set unpacked contents
loop
[total received
< length ]
payload (msgpack format variable length data)
loop
loop
[cap > threashold]
loop[bRet==true]
Overview
Client
msgpack::unpacker
msgpack packets with no length information (e.g. streaming)
2.1. allocate at least N bytes memory
2.reserve_buffer(specific value N)
1.create
3.buf = buffer()
5.R=copy at most “cap” size data into buf
6.buffer_consumed(R)
msgpack::unpacked
7. unp = create
8.bRet = next(unp)
9.obj = get()
10.z = zone()
R is an actual received size
e.g. N=1024
4.cap = buffer_capacity() cap >= N
9
Scenario 2
while cap is enough,
continue receiving
7/16/2014 Copyright OGIS-RI Co., Ltd.
8.1. set unpacked contents
Internal Structure
memory management of unpacker
unpacker
char* m_buffer
size_t m_used
size_t m_free
size_t m_off
size_t m_parsed
size_t m_initial_buffer_size
zone m_z
context m_ctx
char* buffer()
size_t buffer_capacity()
void buffer_consumed(size)
bool next()
...
m_buffer+ m_used
m_free
m_used += size
m_free += size
10
context unpack_stack
unsigned int m_top
unpack_stack m_stack[]
...
undsigned int m_container_type
object m_obj
size_t m_count
...
7/16/2014 Copyright OGIS-RI Co., Ltd.
https://github.com/msgpack/msgpack-c/tree/poc/0.6
The names of data members are based on the
following branch:
Internal Structure
m_parsed = 0
m_buffer
COUNTER_SIZE
The start bytes of m_buffer is used as a reference
counter
constructor(init_size=default_init_size)
If init_size is less than COUNTER_SIZE, then init_size=COUNTER_SIZE.
1
m_used = COUTNER_SIZE
m_free = init_size - m_used
m_off = COUNTER_SIZE
construct
m_buffer m_buffer+m_used
m_m_initial_buffer_size = init_size
117/16/2014 Copyright OGIS-RI Co., Ltd.
unpacker
char* m_buffer
size_t m_used
size_t m_free
size_t m_off
size_t m_parsed
size_t m_initial_buffer_size
zone m_z
context m_ctx
char* buffer()
size_t buffer_capacity()
void buffer_consumed(size)
bool next()
...
m_buffer+ m_used
m_free
m_used += size
m_free += size
memory management of unpacker
received data1
Internal Structure
m_parsed = 0
Write received data into the memory that is returned
by buffer()
1
m_used = COUTNER_SIZE
m_free = init_size - m_used
m_off = COUNTER_SIZE
Writing received data
m_buffer m_buffer+m_used
m_initial_buffer_size = init_size
received data1
m_parsed = 0
m_used += size; m_free -= size;
1
m_free
m_off = COUNTER_SIZE
buffer_consumed(size)
m_buffer
m_initial_buffer_size = init_size
m_buffer+m_used
msgpack(array, size=3)
bool uint32 string
received data1
num
number of array
elements
127/16/2014 Copyright OGIS-RI Co., Ltd.
memory management of unpacker
uint32
boolnum
num
Internal Structure
received data1
m_parsed = 0
Parse from m_buffer+m_off
1
m_free
next()
m_buffer m_buffer + m_usedm_buffer+m_off
received data1
Parse “num”, then store object into the top level of m_ctx.
Advance m_off, increase m_parsed.
1
m_buffer m_buffer + m_off
In order to parse the elements of array, decrement an
internal level of the m_ctx. Parse “bool” and set object
on m_ctx. Advance m_off, increase m_parsed.
msgpack(array, size=3)
bool uint32 string
received data1
num
boolnum
received data11
m_buffer m_buffer + m_off
There are not enough data to parse“uint32”, then return
false. m_off and m_parsed are not updated.
initialize the top level count of
the m_ctx with num
decrement the top level count of
the m_ctx
num
m_parsed
num
m_parsed
bool
13
“num” field means that this is an
array object that has three elements.
array size=numm_stack
m_top
m_stack
m_top
Array structure processes recursively. In order
to implement these processes as loop,
unpacker uses a stack structure.
7/16/2014 Copyright OGIS-RI Co., Ltd.
memory management of unpacker
uint32boolnum
uint32boolnum
received data2
Internal Structure
received data1
Do nothing because m_free >= size.
1
m_free
reserve_buffer(size)
m_buffer m_buffer + m_usedm_buffer + m_off
m_used += size; m_free -= size;
buffer_consumed(size)
received data2received data11
m_free
m_buffer m_buffer + m_used
msgpack(array, size=3)
bool uint32 string
received data1
num
received data2
size
m_buffer+ m_off
num
m_parsed
bool
14
m_stack
m_top
7/16/2014 Copyright OGIS-RI Co., Ltd.
memory management of unpacker
Writing received data
Write received data into the memory that is returned by buffer()
uint32uint32boolnum
m_parsed
uint32boolnum
m_buffer + m_off
m_parsed
string
Internal Structure
received data2received data11
m_free
m_buffer m_buffer + m_usedm_buffer + m_off
next()
received data2received data11
m_free
m_buffer m_buffer + m_used
msgpack(array, size=3)
bool uint32 string
received data1
num
received data2
size
num
m_parsed
bool
15
m_stack
m_top
7/16/2014 Copyright OGIS-RI Co., Ltd.
memory management of unpacker
Parse from m_buffer+m_off
Parse “uint32”, then store object into m_ctx.
Advance m_off, increase m_parsed.
There are not enough data to parse“string”, then return
false. m_off and m_parsed are not updated.
1
string
not parsed data
stringuint32boolnum
Internal Structure
m_free < size then allocate a new buffer.
reserve_buffer(size)
received data2received data1
m_free
m_buffer m_buffer+m_used
msgpack(array, size=3)
bool uint32 string
received data1
num
received data2
size
m_buffer+m_off
received data3
next_size = m_initial_buffer_size
m_initial_buffer_size
not_parsed
not_parsed = m_used - m_off The data that is not parsed yet in the previous buffer.
1
COUNTER_SIZE
While next_size is less than size + not_parsed + COUNTER_SIZE,
next_size *= 2
m_buffer+m_usedm_buffer+m_off
m_free
Update m_off, m_used, m_free as follows:
m_off = COUNTER_SIZE
m_used = not_parsed + COUNTER_SIZE
m_free = next_size - m_used
Decrement the previous buffer’s reference count and if it is zero,
then free it.
uint32bool
num
m_parsed
m_parsed is not updated
16
Copy the not parsed data to newly allocated buffer.
m_stack
m_top
7/16/2014 Copyright OGIS-RI Co., Ltd.
memory management of unpacker
10
string
not parsed data
stringuint32boolnum
Internal Structure
m_free < size then allocate a new buffer.
reserve_buffer(size)
received data2received data1
m_free
m_buffer m_buffer+m_used
msgpack(array, size=3)
bool uint32 string
received data1
num
received data2
size
m_buffer+m_off
received data3
next_size = m_initial_buffer_size
m_initial_buffer_size
not_parsed
not_parsed = m_used - m_off The data that is not parsed yet in the previous buffer.
1
COUNTER_SIZE
While next_size is less than size + not_parsed + COUNTER_SIZE,
next_size *= 2
m_buffer+m_usedm_buffer+m_off
m_free
Update m_off, m_used, m_free as follows:
m_off = COUNTER_SIZE
m_used = not_parsed + COUNTER_SIZE
m_free = next_size - m_used
Decrement the previous buffer’s reference count and if it is zero,
then free it.
uint32bool
num
m_parsed
m_parsed is not updated
17
Copy the not parsed data to newly allocated buffer.
m_stack
m_top
7/16/2014 Copyright OGIS-RI Co., Ltd.
memory management of unpacker
string
not parsed data
Internal Structure
m_free < size then allocate a new buffer.
reserve_buffer(size)
msgpack(array, size=3)
bool uint32 string
received data1
num
received data2
size
received data3
next_size = m_initial_buffer_size
not_parsed = m_used - m_off The data that is not parsed yet in the previous buffer.
1
COUNTER_SIZE
While next_size is less than size + not_parsed + COUNTER_SIZE,
next_size *= 2
m_buffer+m_usedm_buffer+m_off
m_free
Update m_off, m_used, m_free as follows:
m_off = COUNTER_SIZE
m_used = not_parsed + COUNTER_SIZE
m_free = next_size - m_used
Decrement the previous buffer’s reference count and if it is zero,
then free it.
uint32bool
num
m_parsed
m_parsed is not updated
18
Copy the not parsed data to newly allocated buffer.
m_stack
m_top
7/16/2014 Copyright OGIS-RI Co., Ltd.
memory management of unpacker
1
received data3
string
not parsed data
Internal Structure
msgpack(array, size=3)
bool uint32 string
received data1
num
received data2
size
received data3
1
COUNTER_SIZE
m_buffer+m_usedm_buffer+m_off
m_free
m_used += size; m_free -= size;
buffer_consumed(size)
received data3
string
not parsed data1
COUNTER_SIZE
m_buffer+m_usedm_buffer+m_off
m_free
next()
uint32bool
num
m_parsed
received data3
string
not parsed data
COUNTER_SIZE
m_buffer+m_used
m_buffer+m_off
m_free
Decrement the top level count
of m_ctx
string
Because of the top level count of m_ctx is zero, msgpack object has
fully constructed. As the result of that next() returns true.
19
m_stack
m_top
array size=num
7/16/2014 Copyright OGIS-RI Co., Ltd.
memory management of unpacker
Writing received data
Parse from m_buffer+m_off
Write received data into the memory that is
returned by buffer()
Parse “string”, then store object into m_ctx.
Advance m_off, increase m_parsed.
12
received data3
string
not parsed data
Internal Structure
msgpack(array, size=3)
bool uint32 string
received data1
num
received data2
size
received data3
1
COUNTER_SIZE
m_buffer+m_usedm_buffer+m_off
m_free
m_used += size; m_free -= size;
buffer_consumed(size)
received data3
string
not parsed data1
COUNTER_SIZE
m_buffer+m_usedm_buffer+m_off
m_free
next()
uint32bool
num
m_parsed
received data3
string
not parsed data
COUNTER_SIZE
m_buffer+m_used
m_buffer+m_off
m_free
Decrement the top level count
of m_ctx
string
Because of the top level count of m_ctx is zero, msgpack object has
fully constructed. As the result of that next() returns true.
When the msgpack object type is string or bin,
increment the reference counter
20
m_stack
m_top
array size=num
7/16/2014 Copyright OGIS-RI Co., Ltd.
memory management of unpacker
Writing received data
Parse from m_buffer+m_off
Write received data into the memory that is
returned by buffer()
Parse “string”, then store object into m_ctx.
Advance m_off, increase m_parsed.
12
received data3
string
not parsed data
Internal Structure
msgpack(array, size=3)
bool uint32 string
received data1
num
received data2
size
received data3
1
COUNTER_SIZE
m_buffer+m_usedm_buffer+m_off
m_free
m_used += size; m_free -= size;
buffer_consumed(size)
received data3
string
not parsed data1
COUNTER_SIZE
m_buffer+m_usedm_buffer+m_off
m_free
next()
uint32bool
num
m_parsed
received data3
string
not parsed data
COUNTER_SIZE
m_buffer+m_used
m_buffer+m_off
m_free
Decrement the top level count
of m_ctx
string
Because of the top level count of m_ctx is zero, msgpack object has
fully constructed. As the result of that next() returns true.
When the msgpack object type is string or bin,
increment the reference counter
Instead of copy, msgpack object has
a reference of string or bin in the
buffer.
21
m_stack
m_top
array size=num
7/16/2014 Copyright OGIS-RI Co., Ltd.
memory management of unpacker
Writing received data
Parse from m_buffer+m_off
Write received data into the memory that is
returned by buffer()
Parse “string”, then store object into m_ctx.
Advance m_off, increase m_parsed.
zone, unpacker, context, object
22
client
unpacker
create and request unpack
7/16/2014 Copyright OGIS-RI Co., Ltd.
zone, unpacker, context, object
23
client
unpacker
zone
context
buffer
create
createcreate
7/16/2014 Copyright OGIS-RI Co., Ltd.
create and request unpack
zone, unpacker, context, object
24
client
unpacker
zone
context object
buffer
create
createcreate
reference
object(bin,string)
create
place the object on the zone
place the object on the zonemanaged by a reference count
7/16/2014 Copyright OGIS-RI Co., Ltd.
create and request unpack
zone, unpacker, context, object
25
client
unpacker
zone
context object
buffer
create
createcreate
reference
object(bin,string)
create
acquire the ownership from the unpacker
7/16/2014 Copyright OGIS-RI Co., Ltd.
create and request unpack
zone, unpacker, context, object
26
client
zone
object
buffer
reference
object(raw,string)
7/16/2014 Copyright OGIS-RI Co., Ltd.
acquire the ownership from the unpacker

Más contenido relacionado

La actualidad más candente

AWS Blackbelt 2015シリーズ Elastic Load Balancing
AWS Blackbelt 2015シリーズ Elastic Load BalancingAWS Blackbelt 2015シリーズ Elastic Load Balancing
AWS Blackbelt 2015シリーズ Elastic Load BalancingAmazon Web Services Japan
 
DSPでgolangの屍を超えた話 (オレシカナイト Vol.2)
DSPでgolangの屍を超えた話 (オレシカナイト Vol.2)DSPでgolangの屍を超えた話 (オレシカナイト Vol.2)
DSPでgolangの屍を超えた話 (オレシカナイト Vol.2)Yuki Katada
 
ファントム異常を排除する高速なトランザクション処理向けインデックス
ファントム異常を排除する高速なトランザクション処理向けインデックスファントム異常を排除する高速なトランザクション処理向けインデックス
ファントム異常を排除する高速なトランザクション処理向けインデックスSho Nakazono
 
Elasticsearch の検索精度のチューニング 〜テストを作って高速かつ安全に〜
Elasticsearch の検索精度のチューニング 〜テストを作って高速かつ安全に〜Elasticsearch の検索精度のチューニング 〜テストを作って高速かつ安全に〜
Elasticsearch の検索精度のチューニング 〜テストを作って高速かつ安全に〜Takahiko Ito
 
Twitterのリアルタイム分散処理システム「Storm」入門
Twitterのリアルタイム分散処理システム「Storm」入門Twitterのリアルタイム分散処理システム「Storm」入門
Twitterのリアルタイム分散処理システム「Storm」入門AdvancedTechNight
 
Cloud runのオートスケールを検証してみる
Cloud runのオートスケールを検証してみるCloud runのオートスケールを検証してみる
Cloud runのオートスケールを検証してみる虎の穴 開発室
 
テストを書こう!!
テストを書こう!!テストを書こう!!
テストを書こう!!拓 小林
 
AWS Black Belt Techシリーズ Elastic Load Balancing (ELB)
AWS Black Belt Techシリーズ  Elastic Load Balancing (ELB)AWS Black Belt Techシリーズ  Elastic Load Balancing (ELB)
AWS Black Belt Techシリーズ Elastic Load Balancing (ELB)Amazon Web Services Japan
 
ARM CPUにおけるSIMDを用いた高速計算入門
ARM CPUにおけるSIMDを用いた高速計算入門ARM CPUにおけるSIMDを用いた高速計算入門
ARM CPUにおけるSIMDを用いた高速計算入門Fixstars Corporation
 
2015年度GPGPU実践プログラミング 第12回 偏微分方程式の差分計算
2015年度GPGPU実践プログラミング 第12回 偏微分方程式の差分計算2015年度GPGPU実践プログラミング 第12回 偏微分方程式の差分計算
2015年度GPGPU実践プログラミング 第12回 偏微分方程式の差分計算智啓 出川
 
ソーシャルゲーム案件におけるDB分割のPHP実装
ソーシャルゲーム案件におけるDB分割のPHP実装ソーシャルゲーム案件におけるDB分割のPHP実装
ソーシャルゲーム案件におけるDB分割のPHP実装infinite_loop
 
Javaのログ出力: 道具と考え方
Javaのログ出力: 道具と考え方Javaのログ出力: 道具と考え方
Javaのログ出力: 道具と考え方Taku Miyakawa
 
DynamoDB設計のちょっとした技
DynamoDB設計のちょっとした技DynamoDB設計のちょっとした技
DynamoDB設計のちょっとした技Yoichi Toyota
 
ジャストシステムJava100本ノックのご紹介
ジャストシステムJava100本ノックのご紹介ジャストシステムJava100本ノックのご紹介
ジャストシステムJava100本ノックのご紹介JustSystems Corporation
 
テストコード入門
テストコード入門テストコード入門
テストコード入門小川 昌吾
 
Apache Airflow で作る GCP のデータパイプライン @ 酔いどれGCPUG 2017/11/28
Apache Airflow で作る GCP のデータパイプライン @ 酔いどれGCPUG 2017/11/28Apache Airflow で作る GCP のデータパイプライン @ 酔いどれGCPUG 2017/11/28
Apache Airflow で作る GCP のデータパイプライン @ 酔いどれGCPUG 2017/11/28Yuta Hono
 
OSC2011 Tokyo/Spring 自宅SAN友の会(前半)
OSC2011 Tokyo/Spring 自宅SAN友の会(前半)OSC2011 Tokyo/Spring 自宅SAN友の会(前半)
OSC2011 Tokyo/Spring 自宅SAN友の会(前半)Satoshi Shimazaki
 
MySQLと組み合わせて始める全文検索プロダクト"elasticsearch"
MySQLと組み合わせて始める全文検索プロダクト"elasticsearch"MySQLと組み合わせて始める全文検索プロダクト"elasticsearch"
MySQLと組み合わせて始める全文検索プロダクト"elasticsearch"Kentaro Yoshida
 
「今日から使い切る」 ための GNU Parallel による並列処理入門
「今日から使い切る」ための GNU Parallelによる並列処理入門「今日から使い切る」ための GNU Parallelによる並列処理入門
「今日から使い切る」 ための GNU Parallel による並列処理入門Koji Matsuda
 

La actualidad más candente (20)

AWS Blackbelt 2015シリーズ Elastic Load Balancing
AWS Blackbelt 2015シリーズ Elastic Load BalancingAWS Blackbelt 2015シリーズ Elastic Load Balancing
AWS Blackbelt 2015シリーズ Elastic Load Balancing
 
DSPでgolangの屍を超えた話 (オレシカナイト Vol.2)
DSPでgolangの屍を超えた話 (オレシカナイト Vol.2)DSPでgolangの屍を超えた話 (オレシカナイト Vol.2)
DSPでgolangの屍を超えた話 (オレシカナイト Vol.2)
 
ファントム異常を排除する高速なトランザクション処理向けインデックス
ファントム異常を排除する高速なトランザクション処理向けインデックスファントム異常を排除する高速なトランザクション処理向けインデックス
ファントム異常を排除する高速なトランザクション処理向けインデックス
 
Elasticsearch の検索精度のチューニング 〜テストを作って高速かつ安全に〜
Elasticsearch の検索精度のチューニング 〜テストを作って高速かつ安全に〜Elasticsearch の検索精度のチューニング 〜テストを作って高速かつ安全に〜
Elasticsearch の検索精度のチューニング 〜テストを作って高速かつ安全に〜
 
Twitterのリアルタイム分散処理システム「Storm」入門
Twitterのリアルタイム分散処理システム「Storm」入門Twitterのリアルタイム分散処理システム「Storm」入門
Twitterのリアルタイム分散処理システム「Storm」入門
 
Cloud runのオートスケールを検証してみる
Cloud runのオートスケールを検証してみるCloud runのオートスケールを検証してみる
Cloud runのオートスケールを検証してみる
 
テストを書こう!!
テストを書こう!!テストを書こう!!
テストを書こう!!
 
AWS Black Belt Techシリーズ Elastic Load Balancing (ELB)
AWS Black Belt Techシリーズ  Elastic Load Balancing (ELB)AWS Black Belt Techシリーズ  Elastic Load Balancing (ELB)
AWS Black Belt Techシリーズ Elastic Load Balancing (ELB)
 
CUDAメモ
CUDAメモCUDAメモ
CUDAメモ
 
ARM CPUにおけるSIMDを用いた高速計算入門
ARM CPUにおけるSIMDを用いた高速計算入門ARM CPUにおけるSIMDを用いた高速計算入門
ARM CPUにおけるSIMDを用いた高速計算入門
 
2015年度GPGPU実践プログラミング 第12回 偏微分方程式の差分計算
2015年度GPGPU実践プログラミング 第12回 偏微分方程式の差分計算2015年度GPGPU実践プログラミング 第12回 偏微分方程式の差分計算
2015年度GPGPU実践プログラミング 第12回 偏微分方程式の差分計算
 
ソーシャルゲーム案件におけるDB分割のPHP実装
ソーシャルゲーム案件におけるDB分割のPHP実装ソーシャルゲーム案件におけるDB分割のPHP実装
ソーシャルゲーム案件におけるDB分割のPHP実装
 
Javaのログ出力: 道具と考え方
Javaのログ出力: 道具と考え方Javaのログ出力: 道具と考え方
Javaのログ出力: 道具と考え方
 
DynamoDB設計のちょっとした技
DynamoDB設計のちょっとした技DynamoDB設計のちょっとした技
DynamoDB設計のちょっとした技
 
ジャストシステムJava100本ノックのご紹介
ジャストシステムJava100本ノックのご紹介ジャストシステムJava100本ノックのご紹介
ジャストシステムJava100本ノックのご紹介
 
テストコード入門
テストコード入門テストコード入門
テストコード入門
 
Apache Airflow で作る GCP のデータパイプライン @ 酔いどれGCPUG 2017/11/28
Apache Airflow で作る GCP のデータパイプライン @ 酔いどれGCPUG 2017/11/28Apache Airflow で作る GCP のデータパイプライン @ 酔いどれGCPUG 2017/11/28
Apache Airflow で作る GCP のデータパイプライン @ 酔いどれGCPUG 2017/11/28
 
OSC2011 Tokyo/Spring 自宅SAN友の会(前半)
OSC2011 Tokyo/Spring 自宅SAN友の会(前半)OSC2011 Tokyo/Spring 自宅SAN友の会(前半)
OSC2011 Tokyo/Spring 自宅SAN友の会(前半)
 
MySQLと組み合わせて始める全文検索プロダクト"elasticsearch"
MySQLと組み合わせて始める全文検索プロダクト"elasticsearch"MySQLと組み合わせて始める全文検索プロダクト"elasticsearch"
MySQLと組み合わせて始める全文検索プロダクト"elasticsearch"
 
「今日から使い切る」 ための GNU Parallel による並列処理入門
「今日から使い切る」ための GNU Parallelによる並列処理入門「今日から使い切る」ための GNU Parallelによる並列処理入門
「今日から使い切る」 ための GNU Parallel による並列処理入門
 

Similar a MSGPACK_UNPACKER

MessagePack(msgpack): Compact and Fast Serialization Library
MessagePack(msgpack): Compact and Fast Serialization LibraryMessagePack(msgpack): Compact and Fast Serialization Library
MessagePack(msgpack): Compact and Fast Serialization LibraryTakatoshi Kondo
 
ADK COLEGE.pptx
ADK COLEGE.pptxADK COLEGE.pptx
ADK COLEGE.pptxAshirwad2
 
matmultHomework3.pdfNames of Files to Submit matmult..docx
matmultHomework3.pdfNames of Files to Submit  matmult..docxmatmultHomework3.pdfNames of Files to Submit  matmult..docx
matmultHomework3.pdfNames of Files to Submit matmult..docxandreecapon
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimizationveeracynixit
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimizationveeracynixit
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimizationveeracynixit
 
Dma
DmaDma
DmaAcad
 
Using MMS to Build New Environments
Using MMS to Build New EnvironmentsUsing MMS to Build New Environments
Using MMS to Build New EnvironmentsMongoDB
 
MongoDB World 2019: Don't Break the Camel's Back: Running MongoDB as Hard as ...
MongoDB World 2019: Don't Break the Camel's Back: Running MongoDB as Hard as ...MongoDB World 2019: Don't Break the Camel's Back: Running MongoDB as Hard as ...
MongoDB World 2019: Don't Break the Camel's Back: Running MongoDB as Hard as ...MongoDB
 
Everything You Always Wanted to Know About Memory in Python - But Were Afraid...
Everything You Always Wanted to Know About Memory in Python - But Were Afraid...Everything You Always Wanted to Know About Memory in Python - But Were Afraid...
Everything You Always Wanted to Know About Memory in Python - But Were Afraid...Piotr Przymus
 
memory allocation by Novodita
memory allocation by Novoditamemory allocation by Novodita
memory allocation by NovoditaSHRISTEERAI1
 
memory allocation.pptx
memory allocation.pptxmemory allocation.pptx
memory allocation.pptxSHRISTEERAI1
 
Goroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in GoGoroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in GoYu-Shuan Hsieh
 
communication among tasks in advanced system architecture
communication among tasks in advanced system architecturecommunication among tasks in advanced system architecture
communication among tasks in advanced system architectureRoslinJoseph
 
Android - Displaying images
Android - Displaying imagesAndroid - Displaying images
Android - Displaying imagesMatteo Bonifazi
 
PPU Optimisation Lesson
PPU Optimisation LessonPPU Optimisation Lesson
PPU Optimisation Lessonslantsixgames
 
Computer architecture cache memory
Computer architecture cache memoryComputer architecture cache memory
Computer architecture cache memoryMazin Alwaaly
 

Similar a MSGPACK_UNPACKER (20)

MessagePack(msgpack): Compact and Fast Serialization Library
MessagePack(msgpack): Compact and Fast Serialization LibraryMessagePack(msgpack): Compact and Fast Serialization Library
MessagePack(msgpack): Compact and Fast Serialization Library
 
ADK COLEGE.pptx
ADK COLEGE.pptxADK COLEGE.pptx
ADK COLEGE.pptx
 
matmultHomework3.pdfNames of Files to Submit matmult..docx
matmultHomework3.pdfNames of Files to Submit  matmult..docxmatmultHomework3.pdfNames of Files to Submit  matmult..docx
matmultHomework3.pdfNames of Files to Submit matmult..docx
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimization
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimization
 
Android memory and performance optimization
Android memory and performance optimizationAndroid memory and performance optimization
Android memory and performance optimization
 
Dma
DmaDma
Dma
 
Using MMS to Build New Environments
Using MMS to Build New EnvironmentsUsing MMS to Build New Environments
Using MMS to Build New Environments
 
Why learn Internals?
Why learn Internals?Why learn Internals?
Why learn Internals?
 
MongoDB World 2019: Don't Break the Camel's Back: Running MongoDB as Hard as ...
MongoDB World 2019: Don't Break the Camel's Back: Running MongoDB as Hard as ...MongoDB World 2019: Don't Break the Camel's Back: Running MongoDB as Hard as ...
MongoDB World 2019: Don't Break the Camel's Back: Running MongoDB as Hard as ...
 
Everything You Always Wanted to Know About Memory in Python - But Were Afraid...
Everything You Always Wanted to Know About Memory in Python - But Were Afraid...Everything You Always Wanted to Know About Memory in Python - But Were Afraid...
Everything You Always Wanted to Know About Memory in Python - But Were Afraid...
 
memory allocation by Novodita
memory allocation by Novoditamemory allocation by Novodita
memory allocation by Novodita
 
memory allocation.pptx
memory allocation.pptxmemory allocation.pptx
memory allocation.pptx
 
Goroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in GoGoroutine stack and local variable allocation in Go
Goroutine stack and local variable allocation in Go
 
Go on!
Go on!Go on!
Go on!
 
communication among tasks in advanced system architecture
communication among tasks in advanced system architecturecommunication among tasks in advanced system architecture
communication among tasks in advanced system architecture
 
Android - Displaying images
Android - Displaying imagesAndroid - Displaying images
Android - Displaying images
 
PPU Optimisation Lesson
PPU Optimisation LessonPPU Optimisation Lesson
PPU Optimisation Lesson
 
NodeJs Modules.pdf
NodeJs Modules.pdfNodeJs Modules.pdf
NodeJs Modules.pdf
 
Computer architecture cache memory
Computer architecture cache memoryComputer architecture cache memory
Computer architecture cache memory
 

Más de Takatoshi Kondo

CppCon2016 report and Boost.SML
CppCon2016 report and Boost.SMLCppCon2016 report and Boost.SML
CppCon2016 report and Boost.SMLTakatoshi Kondo
 
Pub/Sub model, msm, and asio
Pub/Sub model, msm, and asioPub/Sub model, msm, and asio
Pub/Sub model, msm, and asioTakatoshi Kondo
 
Effective Modern C++ study group Item39
Effective Modern C++ study group Item39Effective Modern C++ study group Item39
Effective Modern C++ study group Item39Takatoshi Kondo
 
Boostsapporomsmpost 111106070819-phpapp02
Boostsapporomsmpost 111106070819-phpapp02Boostsapporomsmpost 111106070819-phpapp02
Boostsapporomsmpost 111106070819-phpapp02Takatoshi Kondo
 
Boostsapporomsmpre 111030054504-phpapp02
Boostsapporomsmpre 111030054504-phpapp02Boostsapporomsmpre 111030054504-phpapp02
Boostsapporomsmpre 111030054504-phpapp02Takatoshi Kondo
 
Aho-Corasick string matching algorithm
Aho-Corasick string matching algorithmAho-Corasick string matching algorithm
Aho-Corasick string matching algorithmTakatoshi Kondo
 

Más de Takatoshi Kondo (10)

CppCon2016 report and Boost.SML
CppCon2016 report and Boost.SMLCppCon2016 report and Boost.SML
CppCon2016 report and Boost.SML
 
Pub/Sub model, msm, and asio
Pub/Sub model, msm, and asioPub/Sub model, msm, and asio
Pub/Sub model, msm, and asio
 
Effective Modern C++ study group Item39
Effective Modern C++ study group Item39Effective Modern C++ study group Item39
Effective Modern C++ study group Item39
 
Boost sg msgpack
Boost sg msgpackBoost sg msgpack
Boost sg msgpack
 
Emcpp0506
Emcpp0506Emcpp0506
Emcpp0506
 
Boostsapporomsmpost 111106070819-phpapp02
Boostsapporomsmpost 111106070819-phpapp02Boostsapporomsmpost 111106070819-phpapp02
Boostsapporomsmpost 111106070819-phpapp02
 
Boostsapporomsmpre 111030054504-phpapp02
Boostsapporomsmpre 111030054504-phpapp02Boostsapporomsmpre 111030054504-phpapp02
Boostsapporomsmpre 111030054504-phpapp02
 
N3495 inplace realloc
N3495 inplace reallocN3495 inplace realloc
N3495 inplace realloc
 
N3701 concept lite
N3701 concept liteN3701 concept lite
N3701 concept lite
 
Aho-Corasick string matching algorithm
Aho-Corasick string matching algorithmAho-Corasick string matching algorithm
Aho-Corasick string matching algorithm
 

Último

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 

Último (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 

MSGPACK_UNPACKER

  • 1. The mechanism of msgpack::unpacker msgpack-c committer Takatoshi Kondo 17/16/2014 Copyright OGIS-RI Co., Ltd.
  • 2. Overview Scenario 1 2 length The length of the “length” field is fixed size length msgpack msgpack msgpack msgpack Scenario 2 Receiving a fixed length msgpack packets msgpack packets with no length information (e.g. streaming) msgpack msgpack msgpack msgpack 7/16/2014 Copyright OGIS-RI Co., Ltd.
  • 3. Overview Client msgpack::unpacker • Client receives msgpack data asynchronously. • Data is separated as packets. • The packet format is as follows: length payload(msgpack format ) 2. receive “length” 3.1. allocate length bytes memory 3.reserve_buffer(length) unpacker may allocate more than “length” bytes for optimization. 1.create 4.buf = buffer() msgpack::unpacked 7. unp = create 8.bRet = next(unp) 8.1. set unpacked contents 9.obj = get() 10.z = zone() 3 Scenario 1 7/16/2014 Copyright OGIS-RI Co., Ltd. 6.buffer_consumed(received) 5. reveived = receive payload into buf
  • 4. Overview Client msgpack::unpacker 3.reserve_buffer(length) 1.create 4.buf = buffer() msgpack::unpacked 7. unp = create 8.bRet = next(unp) 9.obj = get() 10.z = zone() do application processes using obj and z 47/16/2014 Copyright OGIS-RI Co., Ltd. • Client receives msgpack data asynchronously. • Data is separated as packets. • The packet format is as follows: Scenario 1 length payload(msgpack format ) 2. receive “length” 3.1. allocate length bytes memory 8.1. set unpacked contents 6.buffer_consumed(received) 5. reveived = receive payload into buf
  • 5. Overview Client msgpack::unpacker 3.reserve_buffer(length) 1.create 4.buf = buffer() msgpack::unpacked 7. unp = create 8.bRet = next(unp) 9.obj = get() 10.z = zone() loop[bRet==true] next() returns true while an object is unpacked. 57/16/2014 Copyright OGIS-RI Co., Ltd. • Client receives msgpack data asynchronously. • Data is separated as packets. • The packet format is as follows: Scenario 1 length payload(msgpack format ) 2. receive “length” 3.1. allocate length bytes memory 8.1. set unpacked contents 6.buffer_consumed(received) 5. reveived = receive payload into buf
  • 6. loop[bRet==true] Overview Client msgpack::unpacker 3.reserve_buffer(length) 1.create 4.buf = buffer() 6.buffer_consumed(received) msgpack::unpacked 7. unp = create 8.bRet = next(unp) 9.obj = get() 10.z = zone() loop infinite loop for data receiving 67/16/2014 Copyright OGIS-RI Co., Ltd. • Client receives msgpack data asynchronously. • Data is separated as packets. • The packet format is as follows: Scenario 1 length payload(msgpack format ) 2. receive “length” 3.1. allocate length bytes memory 5. reveived = receive payload into buf 8.1. set unpacked contents
  • 7. loop [total received < length ] loop[bRet==true] Overview Client msgpack::unpacker 3.reserve_buffer(length) 1.create 4.buf = buffer() msgpack::unpacked 7. unp = create 8.bRet = next(unp) 9.obj = get() 10.z = zone() When payoads are received intermittently, this loop is effective. If msgpack object is incomplete and additional receive is required, the return false. The position of buf is advanced to received size. 77/16/2014 Copyright OGIS-RI Co., Ltd. • Client receives msgpack data asynchronously. • Data is separated as packets. • The packet format is as follows: Scenario 1 length payload(msgpack format ) 6.buffer_consumed(received) 2. receive “length” 3.1. allocate length bytes memory 5. reveived = receive payload into buf 8.1. set unpacked contents
  • 8. loop loop[bRet==true] Overview Client msgpack::unpacker 3.reserve_buffer(length) 1.create 4.buf = buffer() msgpack::unpacked 7. unp = create 8.bRet = next(unp) 9.obj = get() 10.z = zone() 8 The combination of each loop. 7/16/2014 Copyright OGIS-RI Co., Ltd. • Client receives msgpack data asynchronously. • Data is separated as packets. • The packet format is as follows: Scenario 1 length payload(msgpack format ) 6.buffer_consumed(received) 2. receive “length” 3.1. allocate length bytes memory 5. reveived = receive payload into buf 8.1. set unpacked contents loop [total received < length ]
  • 9. payload (msgpack format variable length data) loop loop [cap > threashold] loop[bRet==true] Overview Client msgpack::unpacker msgpack packets with no length information (e.g. streaming) 2.1. allocate at least N bytes memory 2.reserve_buffer(specific value N) 1.create 3.buf = buffer() 5.R=copy at most “cap” size data into buf 6.buffer_consumed(R) msgpack::unpacked 7. unp = create 8.bRet = next(unp) 9.obj = get() 10.z = zone() R is an actual received size e.g. N=1024 4.cap = buffer_capacity() cap >= N 9 Scenario 2 while cap is enough, continue receiving 7/16/2014 Copyright OGIS-RI Co., Ltd. 8.1. set unpacked contents
  • 10. Internal Structure memory management of unpacker unpacker char* m_buffer size_t m_used size_t m_free size_t m_off size_t m_parsed size_t m_initial_buffer_size zone m_z context m_ctx char* buffer() size_t buffer_capacity() void buffer_consumed(size) bool next() ... m_buffer+ m_used m_free m_used += size m_free += size 10 context unpack_stack unsigned int m_top unpack_stack m_stack[] ... undsigned int m_container_type object m_obj size_t m_count ... 7/16/2014 Copyright OGIS-RI Co., Ltd. https://github.com/msgpack/msgpack-c/tree/poc/0.6 The names of data members are based on the following branch:
  • 11. Internal Structure m_parsed = 0 m_buffer COUNTER_SIZE The start bytes of m_buffer is used as a reference counter constructor(init_size=default_init_size) If init_size is less than COUNTER_SIZE, then init_size=COUNTER_SIZE. 1 m_used = COUTNER_SIZE m_free = init_size - m_used m_off = COUNTER_SIZE construct m_buffer m_buffer+m_used m_m_initial_buffer_size = init_size 117/16/2014 Copyright OGIS-RI Co., Ltd. unpacker char* m_buffer size_t m_used size_t m_free size_t m_off size_t m_parsed size_t m_initial_buffer_size zone m_z context m_ctx char* buffer() size_t buffer_capacity() void buffer_consumed(size) bool next() ... m_buffer+ m_used m_free m_used += size m_free += size memory management of unpacker
  • 12. received data1 Internal Structure m_parsed = 0 Write received data into the memory that is returned by buffer() 1 m_used = COUTNER_SIZE m_free = init_size - m_used m_off = COUNTER_SIZE Writing received data m_buffer m_buffer+m_used m_initial_buffer_size = init_size received data1 m_parsed = 0 m_used += size; m_free -= size; 1 m_free m_off = COUNTER_SIZE buffer_consumed(size) m_buffer m_initial_buffer_size = init_size m_buffer+m_used msgpack(array, size=3) bool uint32 string received data1 num number of array elements 127/16/2014 Copyright OGIS-RI Co., Ltd. memory management of unpacker
  • 13. uint32 boolnum num Internal Structure received data1 m_parsed = 0 Parse from m_buffer+m_off 1 m_free next() m_buffer m_buffer + m_usedm_buffer+m_off received data1 Parse “num”, then store object into the top level of m_ctx. Advance m_off, increase m_parsed. 1 m_buffer m_buffer + m_off In order to parse the elements of array, decrement an internal level of the m_ctx. Parse “bool” and set object on m_ctx. Advance m_off, increase m_parsed. msgpack(array, size=3) bool uint32 string received data1 num boolnum received data11 m_buffer m_buffer + m_off There are not enough data to parse“uint32”, then return false. m_off and m_parsed are not updated. initialize the top level count of the m_ctx with num decrement the top level count of the m_ctx num m_parsed num m_parsed bool 13 “num” field means that this is an array object that has three elements. array size=numm_stack m_top m_stack m_top Array structure processes recursively. In order to implement these processes as loop, unpacker uses a stack structure. 7/16/2014 Copyright OGIS-RI Co., Ltd. memory management of unpacker
  • 14. uint32boolnum uint32boolnum received data2 Internal Structure received data1 Do nothing because m_free >= size. 1 m_free reserve_buffer(size) m_buffer m_buffer + m_usedm_buffer + m_off m_used += size; m_free -= size; buffer_consumed(size) received data2received data11 m_free m_buffer m_buffer + m_used msgpack(array, size=3) bool uint32 string received data1 num received data2 size m_buffer+ m_off num m_parsed bool 14 m_stack m_top 7/16/2014 Copyright OGIS-RI Co., Ltd. memory management of unpacker Writing received data Write received data into the memory that is returned by buffer()
  • 15. uint32uint32boolnum m_parsed uint32boolnum m_buffer + m_off m_parsed string Internal Structure received data2received data11 m_free m_buffer m_buffer + m_usedm_buffer + m_off next() received data2received data11 m_free m_buffer m_buffer + m_used msgpack(array, size=3) bool uint32 string received data1 num received data2 size num m_parsed bool 15 m_stack m_top 7/16/2014 Copyright OGIS-RI Co., Ltd. memory management of unpacker Parse from m_buffer+m_off Parse “uint32”, then store object into m_ctx. Advance m_off, increase m_parsed. There are not enough data to parse“string”, then return false. m_off and m_parsed are not updated.
  • 16. 1 string not parsed data stringuint32boolnum Internal Structure m_free < size then allocate a new buffer. reserve_buffer(size) received data2received data1 m_free m_buffer m_buffer+m_used msgpack(array, size=3) bool uint32 string received data1 num received data2 size m_buffer+m_off received data3 next_size = m_initial_buffer_size m_initial_buffer_size not_parsed not_parsed = m_used - m_off The data that is not parsed yet in the previous buffer. 1 COUNTER_SIZE While next_size is less than size + not_parsed + COUNTER_SIZE, next_size *= 2 m_buffer+m_usedm_buffer+m_off m_free Update m_off, m_used, m_free as follows: m_off = COUNTER_SIZE m_used = not_parsed + COUNTER_SIZE m_free = next_size - m_used Decrement the previous buffer’s reference count and if it is zero, then free it. uint32bool num m_parsed m_parsed is not updated 16 Copy the not parsed data to newly allocated buffer. m_stack m_top 7/16/2014 Copyright OGIS-RI Co., Ltd. memory management of unpacker
  • 17. 10 string not parsed data stringuint32boolnum Internal Structure m_free < size then allocate a new buffer. reserve_buffer(size) received data2received data1 m_free m_buffer m_buffer+m_used msgpack(array, size=3) bool uint32 string received data1 num received data2 size m_buffer+m_off received data3 next_size = m_initial_buffer_size m_initial_buffer_size not_parsed not_parsed = m_used - m_off The data that is not parsed yet in the previous buffer. 1 COUNTER_SIZE While next_size is less than size + not_parsed + COUNTER_SIZE, next_size *= 2 m_buffer+m_usedm_buffer+m_off m_free Update m_off, m_used, m_free as follows: m_off = COUNTER_SIZE m_used = not_parsed + COUNTER_SIZE m_free = next_size - m_used Decrement the previous buffer’s reference count and if it is zero, then free it. uint32bool num m_parsed m_parsed is not updated 17 Copy the not parsed data to newly allocated buffer. m_stack m_top 7/16/2014 Copyright OGIS-RI Co., Ltd. memory management of unpacker
  • 18. string not parsed data Internal Structure m_free < size then allocate a new buffer. reserve_buffer(size) msgpack(array, size=3) bool uint32 string received data1 num received data2 size received data3 next_size = m_initial_buffer_size not_parsed = m_used - m_off The data that is not parsed yet in the previous buffer. 1 COUNTER_SIZE While next_size is less than size + not_parsed + COUNTER_SIZE, next_size *= 2 m_buffer+m_usedm_buffer+m_off m_free Update m_off, m_used, m_free as follows: m_off = COUNTER_SIZE m_used = not_parsed + COUNTER_SIZE m_free = next_size - m_used Decrement the previous buffer’s reference count and if it is zero, then free it. uint32bool num m_parsed m_parsed is not updated 18 Copy the not parsed data to newly allocated buffer. m_stack m_top 7/16/2014 Copyright OGIS-RI Co., Ltd. memory management of unpacker
  • 19. 1 received data3 string not parsed data Internal Structure msgpack(array, size=3) bool uint32 string received data1 num received data2 size received data3 1 COUNTER_SIZE m_buffer+m_usedm_buffer+m_off m_free m_used += size; m_free -= size; buffer_consumed(size) received data3 string not parsed data1 COUNTER_SIZE m_buffer+m_usedm_buffer+m_off m_free next() uint32bool num m_parsed received data3 string not parsed data COUNTER_SIZE m_buffer+m_used m_buffer+m_off m_free Decrement the top level count of m_ctx string Because of the top level count of m_ctx is zero, msgpack object has fully constructed. As the result of that next() returns true. 19 m_stack m_top array size=num 7/16/2014 Copyright OGIS-RI Co., Ltd. memory management of unpacker Writing received data Parse from m_buffer+m_off Write received data into the memory that is returned by buffer() Parse “string”, then store object into m_ctx. Advance m_off, increase m_parsed.
  • 20. 12 received data3 string not parsed data Internal Structure msgpack(array, size=3) bool uint32 string received data1 num received data2 size received data3 1 COUNTER_SIZE m_buffer+m_usedm_buffer+m_off m_free m_used += size; m_free -= size; buffer_consumed(size) received data3 string not parsed data1 COUNTER_SIZE m_buffer+m_usedm_buffer+m_off m_free next() uint32bool num m_parsed received data3 string not parsed data COUNTER_SIZE m_buffer+m_used m_buffer+m_off m_free Decrement the top level count of m_ctx string Because of the top level count of m_ctx is zero, msgpack object has fully constructed. As the result of that next() returns true. When the msgpack object type is string or bin, increment the reference counter 20 m_stack m_top array size=num 7/16/2014 Copyright OGIS-RI Co., Ltd. memory management of unpacker Writing received data Parse from m_buffer+m_off Write received data into the memory that is returned by buffer() Parse “string”, then store object into m_ctx. Advance m_off, increase m_parsed.
  • 21. 12 received data3 string not parsed data Internal Structure msgpack(array, size=3) bool uint32 string received data1 num received data2 size received data3 1 COUNTER_SIZE m_buffer+m_usedm_buffer+m_off m_free m_used += size; m_free -= size; buffer_consumed(size) received data3 string not parsed data1 COUNTER_SIZE m_buffer+m_usedm_buffer+m_off m_free next() uint32bool num m_parsed received data3 string not parsed data COUNTER_SIZE m_buffer+m_used m_buffer+m_off m_free Decrement the top level count of m_ctx string Because of the top level count of m_ctx is zero, msgpack object has fully constructed. As the result of that next() returns true. When the msgpack object type is string or bin, increment the reference counter Instead of copy, msgpack object has a reference of string or bin in the buffer. 21 m_stack m_top array size=num 7/16/2014 Copyright OGIS-RI Co., Ltd. memory management of unpacker Writing received data Parse from m_buffer+m_off Write received data into the memory that is returned by buffer() Parse “string”, then store object into m_ctx. Advance m_off, increase m_parsed.
  • 22. zone, unpacker, context, object 22 client unpacker create and request unpack 7/16/2014 Copyright OGIS-RI Co., Ltd.
  • 23. zone, unpacker, context, object 23 client unpacker zone context buffer create createcreate 7/16/2014 Copyright OGIS-RI Co., Ltd. create and request unpack
  • 24. zone, unpacker, context, object 24 client unpacker zone context object buffer create createcreate reference object(bin,string) create place the object on the zone place the object on the zonemanaged by a reference count 7/16/2014 Copyright OGIS-RI Co., Ltd. create and request unpack
  • 25. zone, unpacker, context, object 25 client unpacker zone context object buffer create createcreate reference object(bin,string) create acquire the ownership from the unpacker 7/16/2014 Copyright OGIS-RI Co., Ltd. create and request unpack
  • 26. zone, unpacker, context, object 26 client zone object buffer reference object(raw,string) 7/16/2014 Copyright OGIS-RI Co., Ltd. acquire the ownership from the unpacker