Skip to content

Commit

Permalink
2.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
ijl committed Sep 25, 2019
1 parent 1b64cb1 commit 8cc10c8
Show file tree
Hide file tree
Showing 15 changed files with 150 additions and 90 deletions.
Empty file removed .gitmodules
Empty file.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 2.0.19 - 2019-09-25

### Changed

- Performance improvements and lower memory usage in deserialization
by creating only one `str` object for repeated map keys.

## 2.0.9 - 2019-09-22

### Changed
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "orjson"
version = "2.0.9"
version = "2.0.10"
authors = ["ijl <ijl@mailbox.org>"]
description = "Fast, correct Python JSON library"
edition = "2018"
Expand Down
187 changes: 101 additions & 86 deletions README.md

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions bench/mem_usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

import io
import subprocess

from tabulate import tabulate

buf = io.StringIO()

headers = ("Library", "RSS change after loads() (MiB)")

LIBRARIES = ("orjson", "ujson", "rapidjson", "json", "simplejson")

FIXTURES = ("canada.json", "citm_catalog.json", "github.json", "twitter.json")

for fixture in sorted(FIXTURES, reverse=True):
table = []
buf.write("\n" + "#### " + fixture + "\n\n")
for lib_name in LIBRARIES:
proc = subprocess.Popen(
("bench/run_mem", f"data/{fixture}.xz", lib_name), stdout=subprocess.PIPE
)
output = proc.stdout.readline().decode("utf-8").split(",")
mem_base = int(output[0]) / 1024 / 1024
mem_diff = int(output[1]) / 1024 / 1024
table.append((lib_name, f"+{mem_diff:,.1f}"))
buf.write(tabulate(table, headers, tablefmt="grid") + "\n")

print(
buf.getvalue()
.replace("-", "")
.replace("=", "-")
.replace("+", "|")
.replace("||||", "")
.replace("\n\n", "\n")
)
5 changes: 3 additions & 2 deletions bench/run_mem
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import psutil
filename = sys.argv[1]

with lzma.open(filename, "r") as fileh:
file_utf8 = fileh.read()
fixture = fileh.read()

proc = psutil.Process()

Expand All @@ -32,7 +32,8 @@ gc.collect()

mem_before = proc.memory_info().rss

val = loads(file_utf8)
for _ in range(100):
val = loads(fixture)

mem_after = proc.memory_info().rss

Expand Down
Binary file modified doc/canada_deserialization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/canada_serialization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/citm_catalog_deserialization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/citm_catalog_serialization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/github_deserialization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/github_serialization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/twitter_deserialization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/twitter_serialization.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8cc10c8

Please sign in to comment.