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

Indian Case Studies: How AWS Customers Have Successfully Built and Migrated a...
Indian Case Studies: How AWS Customers Have Successfully Built and Migrated a...Indian Case Studies: How AWS Customers Have Successfully Built and Migrated a...
Indian Case Studies: How AWS Customers Have Successfully Built and Migrated a...Amazon Web Services
 
Deconstructing SaaS: Deep Dive into Building Multi-Tenant Solutions on AWS (A...
Deconstructing SaaS: Deep Dive into Building Multi-Tenant Solutions on AWS (A...Deconstructing SaaS: Deep Dive into Building Multi-Tenant Solutions on AWS (A...
Deconstructing SaaS: Deep Dive into Building Multi-Tenant Solutions on AWS (A...Amazon Web Services
 
CloudFormation/SAMのススメ
CloudFormation/SAMのススメCloudFormation/SAMのススメ
CloudFormation/SAMのススメEiji KOMINAMI
 
[DO05] システムの信頼性を上げるための新しい考え方 SRE ( Site Reliability Engineering ) in Azure, o...
[DO05] システムの信頼性を上げるための新しい考え方 SRE ( Site Reliability Engineering ) in Azure, o...[DO05] システムの信頼性を上げるための新しい考え方 SRE ( Site Reliability Engineering ) in Azure, o...
[DO05] システムの信頼性を上げるための新しい考え方 SRE ( Site Reliability Engineering ) in Azure, o...de:code 2017
 
ここまできた! Google Cloud Platform Virtual Private Cloud 徹底解説
ここまできた! Google Cloud Platform Virtual Private Cloud 徹底解説ここまできた! Google Cloud Platform Virtual Private Cloud 徹底解説
ここまできた! Google Cloud Platform Virtual Private Cloud 徹底解説Yuta Hono
 
Automating Management of Amazon EC2 Instances with Auto Scaling - March 2017 ...
Automating Management of Amazon EC2 Instances with Auto Scaling - March 2017 ...Automating Management of Amazon EC2 Instances with Auto Scaling - March 2017 ...
Automating Management of Amazon EC2 Instances with Auto Scaling - March 2017 ...Amazon Web Services
 
Azure Functions&Logic Appではじめるサーバレスアプリケーション開発 - 入門編 -
Azure Functions&Logic Appではじめるサーバレスアプリケーション開発 - 入門編 -Azure Functions&Logic Appではじめるサーバレスアプリケーション開発 - 入門編 -
Azure Functions&Logic Appではじめるサーバレスアプリケーション開発 - 入門編 -Yoichi Kawasaki
 
[Cloud OnAir] 安心して GCP を使うための処方箋 ~ 実際のインシデントをもとに ~ 2019年11月14日 放送
[Cloud OnAir] 安心して GCP を使うための処方箋 ~ 実際のインシデントをもとに ~ 2019年11月14日 放送[Cloud OnAir] 安心して GCP を使うための処方箋 ~ 実際のインシデントをもとに ~ 2019年11月14日 放送
[Cloud OnAir] 安心して GCP を使うための処方箋 ~ 実際のインシデントをもとに ~ 2019年11月14日 放送Google Cloud Platform - Japan
 
AWS Black Belt Techシリーズ Amazon SNS / Amazon SQS
AWS Black Belt Techシリーズ Amazon SNS / Amazon SQSAWS Black Belt Techシリーズ Amazon SNS / Amazon SQS
AWS Black Belt Techシリーズ Amazon SNS / Amazon SQSAmazon Web Services Japan
 
実践 Amazon KMS #cmdevio2015
実践 Amazon KMS #cmdevio2015実践 Amazon KMS #cmdevio2015
実践 Amazon KMS #cmdevio2015y torazuka
 
Ansible AWXで一歩進んだプロビジョニング
Ansible AWXで一歩進んだプロビジョニングAnsible AWXで一歩進んだプロビジョニング
Ansible AWXで一歩進んだプロビジョニングsugoto
 
Oscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleOscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleMartin Odersky
 
AWS Black Belt Techシリーズ Cost Explorer
AWS Black Belt Techシリーズ Cost ExplorerAWS Black Belt Techシリーズ Cost Explorer
AWS Black Belt Techシリーズ Cost ExplorerAmazon Web Services Japan
 
Speed and Reliability at Any Scale: Amazon SQS and Database Services (SVC206)...
Speed and Reliability at Any Scale: Amazon SQS and Database Services (SVC206)...Speed and Reliability at Any Scale: Amazon SQS and Database Services (SVC206)...
Speed and Reliability at Any Scale: Amazon SQS and Database Services (SVC206)...Amazon Web Services
 
[Cloud OnAir] GCP でできる Lift & Shift 〜 移行支援ツールも各種ご紹介 〜 2019年1月17日 放送
[Cloud OnAir] GCP でできる Lift & Shift 〜 移行支援ツールも各種ご紹介 〜 2019年1月17日 放送[Cloud OnAir] GCP でできる Lift & Shift 〜 移行支援ツールも各種ご紹介 〜 2019年1月17日 放送
[Cloud OnAir] GCP でできる Lift & Shift 〜 移行支援ツールも各種ご紹介 〜 2019年1月17日 放送Google Cloud Platform - Japan
 
GitOpsでKubernetesのManifest管理
GitOpsでKubernetesのManifest管理GitOpsでKubernetesのManifest管理
GitOpsでKubernetesのManifest管理Shinya Sasaki
 
AWS Black Belt Online Seminar AWS Key Management Service (KMS)
AWS Black Belt Online Seminar AWS Key Management Service (KMS) AWS Black Belt Online Seminar AWS Key Management Service (KMS)
AWS Black Belt Online Seminar AWS Key Management Service (KMS) Amazon Web Services Japan
 

La actualidad más candente (20)

Indian Case Studies: How AWS Customers Have Successfully Built and Migrated a...
Indian Case Studies: How AWS Customers Have Successfully Built and Migrated a...Indian Case Studies: How AWS Customers Have Successfully Built and Migrated a...
Indian Case Studies: How AWS Customers Have Successfully Built and Migrated a...
 
Deconstructing SaaS: Deep Dive into Building Multi-Tenant Solutions on AWS (A...
Deconstructing SaaS: Deep Dive into Building Multi-Tenant Solutions on AWS (A...Deconstructing SaaS: Deep Dive into Building Multi-Tenant Solutions on AWS (A...
Deconstructing SaaS: Deep Dive into Building Multi-Tenant Solutions on AWS (A...
 
Security hub workshop
Security hub workshopSecurity hub workshop
Security hub workshop
 
CloudFormation/SAMのススメ
CloudFormation/SAMのススメCloudFormation/SAMのススメ
CloudFormation/SAMのススメ
 
[DO05] システムの信頼性を上げるための新しい考え方 SRE ( Site Reliability Engineering ) in Azure, o...
[DO05] システムの信頼性を上げるための新しい考え方 SRE ( Site Reliability Engineering ) in Azure, o...[DO05] システムの信頼性を上げるための新しい考え方 SRE ( Site Reliability Engineering ) in Azure, o...
[DO05] システムの信頼性を上げるための新しい考え方 SRE ( Site Reliability Engineering ) in Azure, o...
 
ここまできた! Google Cloud Platform Virtual Private Cloud 徹底解説
ここまできた! Google Cloud Platform Virtual Private Cloud 徹底解説ここまできた! Google Cloud Platform Virtual Private Cloud 徹底解説
ここまできた! Google Cloud Platform Virtual Private Cloud 徹底解説
 
Automating Management of Amazon EC2 Instances with Auto Scaling - March 2017 ...
Automating Management of Amazon EC2 Instances with Auto Scaling - March 2017 ...Automating Management of Amazon EC2 Instances with Auto Scaling - March 2017 ...
Automating Management of Amazon EC2 Instances with Auto Scaling - March 2017 ...
 
Azure Functions&Logic Appではじめるサーバレスアプリケーション開発 - 入門編 -
Azure Functions&Logic Appではじめるサーバレスアプリケーション開発 - 入門編 -Azure Functions&Logic Appではじめるサーバレスアプリケーション開発 - 入門編 -
Azure Functions&Logic Appではじめるサーバレスアプリケーション開発 - 入門編 -
 
[Cloud OnAir] 安心して GCP を使うための処方箋 ~ 実際のインシデントをもとに ~ 2019年11月14日 放送
[Cloud OnAir] 安心して GCP を使うための処方箋 ~ 実際のインシデントをもとに ~ 2019年11月14日 放送[Cloud OnAir] 安心して GCP を使うための処方箋 ~ 実際のインシデントをもとに ~ 2019年11月14日 放送
[Cloud OnAir] 安心して GCP を使うための処方箋 ~ 実際のインシデントをもとに ~ 2019年11月14日 放送
 
AWS Black Belt Techシリーズ Amazon SNS / Amazon SQS
AWS Black Belt Techシリーズ Amazon SNS / Amazon SQSAWS Black Belt Techシリーズ Amazon SNS / Amazon SQS
AWS Black Belt Techシリーズ Amazon SNS / Amazon SQS
 
実践 Amazon KMS #cmdevio2015
実践 Amazon KMS #cmdevio2015実践 Amazon KMS #cmdevio2015
実践 Amazon KMS #cmdevio2015
 
Ansible AWXで一歩進んだプロビジョニング
Ansible AWXで一歩進んだプロビジョニングAnsible AWXで一歩進んだプロビジョニング
Ansible AWXで一歩進んだプロビジョニング
 
Oscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simpleOscon keynote: Working hard to keep it simple
Oscon keynote: Working hard to keep it simple
 
AWS Black Belt Techシリーズ Cost Explorer
AWS Black Belt Techシリーズ Cost ExplorerAWS Black Belt Techシリーズ Cost Explorer
AWS Black Belt Techシリーズ Cost Explorer
 
Speed and Reliability at Any Scale: Amazon SQS and Database Services (SVC206)...
Speed and Reliability at Any Scale: Amazon SQS and Database Services (SVC206)...Speed and Reliability at Any Scale: Amazon SQS and Database Services (SVC206)...
Speed and Reliability at Any Scale: Amazon SQS and Database Services (SVC206)...
 
[Cloud OnAir] GCP でできる Lift & Shift 〜 移行支援ツールも各種ご紹介 〜 2019年1月17日 放送
[Cloud OnAir] GCP でできる Lift & Shift 〜 移行支援ツールも各種ご紹介 〜 2019年1月17日 放送[Cloud OnAir] GCP でできる Lift & Shift 〜 移行支援ツールも各種ご紹介 〜 2019年1月17日 放送
[Cloud OnAir] GCP でできる Lift & Shift 〜 移行支援ツールも各種ご紹介 〜 2019年1月17日 放送
 
Unit 4
Unit 4Unit 4
Unit 4
 
GitOpsでKubernetesのManifest管理
GitOpsでKubernetesのManifest管理GitOpsでKubernetesのManifest管理
GitOpsでKubernetesのManifest管理
 
AWS Black Belt Online Seminar AWS Key Management Service (KMS)
AWS Black Belt Online Seminar AWS Key Management Service (KMS) AWS Black Belt Online Seminar AWS Key Management Service (KMS)
AWS Black Belt Online Seminar AWS Key Management Service (KMS)
 
Pm2
Pm2Pm2
Pm2
 

Similar a Unpack mechanism of the msgpack-c

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
 
Introduction to Data Structures, Data Structures using C.pptx
Introduction to Data Structures, Data Structures using C.pptxIntroduction to Data Structures, Data Structures using C.pptx
Introduction to Data Structures, Data Structures using C.pptxpoongothai11
 
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
 

Similar a Unpack mechanism of the msgpack-c (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?
 
Introduction to Data Structures, Data Structures using C.pptx
Introduction to Data Structures, Data Structures using C.pptxIntroduction to Data Structures, Data Structures using C.pptx
Introduction to Data Structures, Data Structures using C.pptx
 
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
 

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

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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Último (20)

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
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Unpack mechanism of the msgpack-c

  • 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