Skip to content

Commit 57a628f

Browse files
committed
DEV: update examples on two JSON pages
1 parent 778ed3c commit 57a628f

File tree

2 files changed

+23
-26
lines changed
  • content

2 files changed

+23
-26
lines changed

content/commands/json.debug-memory/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Get the values' memory usage in bytes.
6969

7070
{{< highlight bash >}}
7171
redis> JSON.DEBUG MEMORY item:2
72-
(integer) 253
72+
(integer) 685
7373
{{< / highlight >}}
7474
</details>
7575

content/develop/data-types/json/ram.md

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ categories:
99
- oss
1010
- kubernetes
1111
- clients
12-
description: 'Debugging memory consumption
13-
14-
'
12+
description: Debugging memory consumption
1513
linkTitle: Memory Usage
1614
title: Redis JSON RAM Usage
1715
weight: 6
@@ -22,15 +20,15 @@ well as some per-key overhead that Redis uses. On top of that, the value in the
2220
RAM.
2321

2422
Redis JSON stores JSON values as binary data after deserializing them. This representation is often more
25-
expensive, size-wise, than the serialized form. The JSON data type uses at least 24 bytes (on
23+
expensive, size-wise, than the serialized form. The JSON data type uses at least 8 bytes (on
2624
64-bit architectures) for every value, as can be seen by sampling an empty string with the
2725
[`JSON.DEBUG MEMORY`]({{< relref "commands/json.debug-memory/" >}}) command:
2826

2927
```
3028
127.0.0.1:6379> JSON.SET emptystring . '""'
3129
OK
3230
127.0.0.1:6379> JSON.DEBUG MEMORY emptystring
33-
(integer) 24
31+
(integer) 8
3432
```
3533

3634
This RAM requirement is the same for all scalar values, but strings require additional space
@@ -40,20 +38,20 @@ depending on their actual length. For example, a 3-character string will use 3 a
4038
127.0.0.1:6379> JSON.SET foo . '"bar"'
4139
OK
4240
127.0.0.1:6379> JSON.DEBUG MEMORY foo
43-
(integer) 27
41+
(integer) 11
4442
```
4543

46-
Empty containers take up 32 bytes to set up:
44+
Empty containers take up 8 bytes to set up:
4745

4846
```
4947
127.0.0.1:6379> JSON.SET arr . '[]'
5048
OK
5149
127.0.0.1:6379> JSON.DEBUG MEMORY arr
52-
(integer) 32
50+
(integer) 8
5351
127.0.0.1:6379> JSON.SET obj . '{}'
5452
OK
5553
127.0.0.1:6379> JSON.DEBUG MEMORY obj
56-
(integer) 32
54+
(integer) 8
5755
```
5856

5957
The actual size of a container is the sum of sizes of all items in it on top of its own
@@ -65,7 +63,7 @@ A container with a single scalar is made up of 32 and 24 bytes, respectively:
6563
127.0.0.1:6379> JSON.SET arr . '[""]'
6664
OK
6765
127.0.0.1:6379> JSON.DEBUG MEMORY arr
68-
(integer) 56
66+
(integer) 64
6967
```
7068

7169
A container with two scalars requires 40 bytes for the container (each pointer to an entry in the
@@ -74,7 +72,7 @@ container is 8 bytes), and 2 * 24 bytes for the values themselves:
7472
127.0.0.1:6379> JSON.SET arr . '["", ""]'
7573
OK
7674
127.0.0.1:6379> JSON.DEBUG MEMORY arr
77-
(integer) 88
75+
(integer) 72
7876
```
7977

8078
A 3-item (each 24 bytes) container will be allocated with capacity for 4 items, i.e. 56 bytes:
@@ -83,7 +81,7 @@ A 3-item (each 24 bytes) container will be allocated with capacity for 4 items,
8381
127.0.0.1:6379> JSON.SET arr . '["", "", ""]'
8482
OK
8583
127.0.0.1:6379> JSON.DEBUG MEMORY arr
86-
(integer) 128
84+
(integer) 80
8785
```
8886

8987
The next item will not require an allocation in the container, so usage will increase only by that
@@ -93,24 +91,23 @@ scalar's requirement, but another value will scale the container again:
9391
127.0.0.1:6379> JSON.SET arr . '["", "", "", ""]'
9492
OK
9593
127.0.0.1:6379> JSON.DEBUG MEMORY arr
96-
(integer) 152
94+
(integer) 88
9795
127.0.0.1:6379> JSON.SET arr . '["", "", "", "", ""]'
9896
OK
9997
127.0.0.1:6379> JSON.DEBUG MEMORY arr
100-
(integer) 208
98+
(integer) 128
10199
```
102100

103-
This table gives the size (in bytes) of a few of the test files on disk and when stored using
104-
JSON. The _MessagePack_ column is for reference purposes and reflects the length of the value
105-
when stored using MessagePack.
106-
107-
| File | Filesize | Redis JSON | MessagePack |
108-
| -------------------------------------- | --------- | ------ | ----------- |
109-
| /tests/files/pass-100.json | 380 | 1079 | 140 |
110-
| /tests/files/pass-jsonsl-1.json | 1441 | 3666 | 753 |
111-
| /tests/files/pass-json-parser-0000.json | 3468 | 7209 | 2393 |
112-
| /tests/files/pass-jsonsl-yahoo2.json | 18446 | 37469 | 16869 |
113-
| /tests/files/pass-jsonsl-yelp.json | 39491 | 75341 | 35469 |
101+
This table gives the size (in bytes) of a few of the test files from the [module repo](https://github.com/RedisJSON/RedisJSON), stored using
102+
JSON. The _MessagePack_ column is for reference purposes and reflects the length of the value when stored using [MessagePack](https://msgpack.org/index.html).
103+
104+
| File | File size | Redis JSON | MessagePack |
105+
| --------------------------------------- | --------- | ---------- | ----------- |
106+
| /tests/files/pass-100.json | 381 | 1349 | 140 |
107+
| /tests/files/pass-jsonsl-1.json | 1387 | 2734 | 757 |
108+
| /tests/files/pass-json-parser-0000.json | 3718 | 6157 | 2393 |
109+
| /tests/files/pass-jsonsl-yahoo2.json | 22466 | 29957 | 16869 |
110+
| /tests/files/pass-jsonsl-yelp.json | 46333 | 63489 | 35529 |
114111

115112
> Note: In the current version, deleting values from containers **does not** free the container's
116113
allocated memory.

0 commit comments

Comments
 (0)