Skip to content

Commit

Permalink
cargo update, build misc
Browse files Browse the repository at this point in the history
  • Loading branch information
ijl committed Nov 15, 2024
1 parent 8ece0d4 commit 8d4e289
Show file tree
Hide file tree
Showing 23 changed files with 307 additions and 290 deletions.
58 changes: 32 additions & 26 deletions .github/workflows/artifact.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,25 @@ jobs:
{
cc: "clang",
cflags: "-Os -fstrict-aliasing -fno-plt -flto=full -emit-llvm",
features: "avx512,no-panic,unstable-simd,yyjson",
features: "avx512,unstable-simd,yyjson",
ldflags: "-fuse-ld=lld -Wl,-plugin-opt=also-emit-llvm -Wl,--as-needed -Wl,-zrelro,-znow",
rustflags: "-C linker=clang -C link-arg=-fuse-ld=lld -C linker-plugin-lto -C lto=fat -C link-arg=-Wl,-zrelro,-znow -Z mir-opt-level=4 -Z threads=4 -D warnings",
tag: null,
target: "x86_64-unknown-linux-gnu",
},
]
env:
PYTHON: "${{ matrix.python.interpreter }}"
PYTHON_PACKAGE: "${{ matrix.python.package }}"
TARGET: "${{ matrix.arch.target }}"
CARGO_TARGET_DIR: "/tmp/orjson"
CC: "${{ matrix.arch.cc }}"
VENV: ".venv"
FEATURES: "${{ matrix.arch.features }}"
CFLAGS: "${{ matrix.arch.cflags }}"
COMPATIBILITY: "${{ matrix.python.compatibility }}"
FEATURES: "${{ matrix.arch.features }}"
LDFLAGS: "${{ matrix.arch.ldflags }}"
PYTHON: "${{ matrix.python.interpreter }}"
PYTHON_PACKAGE: "${{ matrix.python.package }}"
RUSTFLAGS: "${{ matrix.arch.rustflags }}"
CARGO_TARGET_DIR: "/tmp/orjson"
COMPATIBILITY: "${{ matrix.python.compatibility }}"
TARGET: "${{ matrix.arch.target }}"
VENV: ".venv"
steps:

- name: cpuinfo
Expand Down Expand Up @@ -167,25 +167,25 @@ jobs:
{
cc: "clang",
cflags: "-Os -fstrict-aliasing -fno-plt -flto=full -emit-llvm",
features: "no-panic,unstable-simd,yyjson",
features: "unstable-simd,yyjson",
ldflags: "-fuse-ld=lld -Wl,-plugin-opt=also-emit-llvm -Wl,--as-needed -Wl,-zrelro,-znow",
rustflags: "-C linker=clang -C link-arg=-fuse-ld=lld -C linker-plugin-lto -C lto=fat -C link-arg=-Wl,-zrelro,-znow -Z mir-opt-level=4 -Z threads=4 -D warnings",
tag: "aarch64",
target: "aarch64-unknown-linux-gnu",
},
]
env:
PYTHON: "${{ matrix.python.interpreter }}"
PYTHON_PACKAGE: "${{ matrix.python.package }}"
TARGET: "${{ matrix.arch.target }}"
CARGO_TARGET_DIR: "/tmp/orjson"
CC: "${{ matrix.arch.cc }}"
VENV: ".venv"
FEATURES: "${{ matrix.arch.features }}"
CFLAGS: "${{ matrix.arch.cflags }}"
COMPATIBILITY: "${{ matrix.python.compatibility }}"
FEATURES: "${{ matrix.arch.features }}"
LDFLAGS: "${{ matrix.arch.ldflags }}"
PYTHON: "${{ matrix.python.interpreter }}"
PYTHON_PACKAGE: "${{ matrix.python.package }}"
RUSTFLAGS: "${{ matrix.arch.rustflags }}"
CARGO_TARGET_DIR: "/tmp/orjson"
COMPATIBILITY: "${{ matrix.python.compatibility }}"
TARGET: "${{ matrix.arch.target }}"
VENV: ".venv"
steps:

- name: cpuinfo
Expand Down Expand Up @@ -256,11 +256,11 @@ jobs:
- target: aarch64-unknown-linux-musl
arch: aarch64
platform: linux/arm64
features: no-panic,unstable-simd,unwind,yyjson
features: unstable-simd,unwind,yyjson
- target: x86_64-unknown-linux-musl
arch: x86_64
platform: linux/amd64
features: avx512,no-panic,unstable-simd,unwind,yyjson
features: avx512,unstable-simd,unwind,yyjson
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -331,28 +331,28 @@ jobs:
{
arch: 'aarch64',
cflags: '-Os -flto=full -fstrict-aliasing',
features: 'no-panic,unstable-simd,yyjson',
features: 'unstable-simd,yyjson',
rustflags: '-Z mir-opt-level=4 -C lto=fat -D warnings',
target: 'aarch64-unknown-linux-gnu',
},
{
arch: 'armv7',
cflags: '-Os -flto=full -fstrict-aliasing',
features: 'no-panic,yyjson', # no SIMD
features: 'yyjson', # no SIMD
rustflags: '-Z mir-opt-level=4 -C lto=fat -D warnings -C opt-level=s',
target: 'armv7-unknown-linux-gnueabihf',
},
{
arch: 'ppc64le',
cflags: '-Os -flto=full -fstrict-aliasing',
features: 'no-panic,unstable-simd,yyjson',
features: 'unstable-simd,yyjson',
rustflags: '-Z mir-opt-level=4 -C lto=fat -D warnings',
target: 'powerpc64le-unknown-linux-gnu',
},
{
arch: 's390x',
cflags: '-Os -flto=full -fstrict-aliasing -march=z10',
features: 'no-panic,yyjson',
features: 'yyjson',
rustflags: '-Z mir-opt-level=4 -C lto=fat -D warnings -C target-cpu=z10',
target: 's390x-unknown-linux-gnu',
},
Expand Down Expand Up @@ -426,6 +426,8 @@ jobs:
run: |
cargo fetch --target aarch64-apple-darwin &
export PATH=$HOME/.cargo/bin:$HOME/.local/bin:$PATH
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv --python python${{ matrix.python.version }}
uv pip install --upgrade "maturin>=1,<2" -r test/requirements.txt -r integration/requirements.txt
Expand All @@ -435,11 +437,12 @@ jobs:
- name: maturin
run: |
PATH=$HOME/.cargo/bin:$PATH \
export PATH=$HOME/.cargo/bin:$HOME/.local/bin:$PATH
MACOSX_DEPLOYMENT_TARGET="${{ matrix.python.macosx_target }}" \
PYO3_CROSS_LIB_DIR=$(python -c "import sysconfig;print(sysconfig.get_config_var('LIBDIR'))") \
maturin build --release --strip \
--features=no-panic,unstable-simd,yyjson \
--features=unstable-simd,yyjson \
--interpreter python${{ matrix.python.version }} \
--target=universal2-apple-darwin
uv pip install target/wheels/orjson*.whl
Expand Down Expand Up @@ -496,6 +499,8 @@ jobs:
run: |
cargo fetch --target aarch64-apple-darwin &
export PATH=$HOME/.cargo/bin:$HOME/.local/bin:$PATH
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv --python python${{ matrix.python.version }}
uv pip install --upgrade "maturin>=1,<2" -r test/requirements.txt -r integration/requirements.txt
Expand All @@ -505,11 +510,12 @@ jobs:
- name: maturin
run: |
PATH=$HOME/.cargo/bin:$PATH \
export PATH=$HOME/.cargo/bin:$HOME/.local/bin:$PATH
MACOSX_DEPLOYMENT_TARGET="${{ matrix.python.macosx_target }}" \
PYO3_CROSS_LIB_DIR=$(python -c "import sysconfig;print(sysconfig.get_config_var('LIBDIR'))") \
maturin build --release --strip \
--features=no-panic,unstable-simd,yyjson \
--features=unstable-simd,yyjson \
--interpreter python${{ matrix.python.version }} \
--target=universal2-apple-darwin
uv pip install target/wheels/orjson*.whl
Expand Down
37 changes: 10 additions & 27 deletions Cargo.lock

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

6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ unstable-simd = []
# Include runtime-detected functions that use AVX512VL. Requires unstable-simd and amd64.
avx512 = []

no-panic = [
"itoa/no-panic",
"ryu/no-panic",
]

# Avoid bundling libgcc on musl.
unwind = ["unwinding"]

Expand All @@ -51,6 +46,7 @@ unwind = ["unwinding"]
yyjson = []

# Features detected by build.rs. Do not specify.
assert_unchecked = []
inline_int = []
intrinsics = []
optimize = []
Expand Down
59 changes: 4 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ available in the repository.
3. [Testing](https://github.com/ijl/orjson?tab=readme-ov-file#testing)
4. [Performance](https://github.com/ijl/orjson?tab=readme-ov-file#performance)
1. [Latency](https://github.com/ijl/orjson?tab=readme-ov-file#latency)
2. [Memory](https://github.com/ijl/orjson?tab=readme-ov-file#memory)
3. [Reproducing](https://github.com/ijl/orjson?tab=readme-ov-file#reproducing)
2. [Reproducing](https://github.com/ijl/orjson?tab=readme-ov-file#reproducing)
5. [Questions](https://github.com/ijl/orjson?tab=readme-ov-file#questions)
6. [Packaging](https://github.com/ijl/orjson?tab=readme-ov-file#packaging)
7. [License](https://github.com/ijl/orjson?tab=readme-ov-file#license)
Expand Down Expand Up @@ -1120,64 +1119,13 @@ format, containing floats and arrays, indented.
| simplejson | 16.8 | 59 | 5.6 |
| json | 18.2 | 55 | 6.1 |

### Memory

orjson as of 3.7.0 has higher baseline memory usage than other libraries
due to a persistent buffer used for parsing. Incremental memory usage when
deserializing is similar to the standard library and other third-party
libraries.

This measures, in the first column, RSS after importing a library and reading
the fixture, and in the second column, increases in RSS after repeatedly
calling `loads()` on the fixture.

#### twitter.json

| Library | import, read() RSS (MiB) | loads() increase in RSS (MiB) |
|------------|----------------------------|---------------------------------|
| orjson | 15.7 | 3.4 |
| ujson | 16.4 | 3.4 |
| rapidjson | 16.6 | 4.4 |
| simplejson | 14.5 | 1.8 |
| json | 13.9 | 1.8 |

#### github.json

| Library | import, read() RSS (MiB) | loads() increase in RSS (MiB) |
|------------|----------------------------|---------------------------------|
| orjson | 15.2 | 0.4 |
| ujson | 15.4 | 0.4 |
| rapidjson | 15.7 | 0.5 |
| simplejson | 13.7 | 0.2 |
| json | 13.3 | 0.1 |

#### citm_catalog.json

| Library | import, read() RSS (MiB) | loads() increase in RSS (MiB) |
|------------|----------------------------|---------------------------------|
| orjson | 16.8 | 10.1 |
| ujson | 17.3 | 10.2 |
| rapidjson | 17.6 | 28.7 |
| simplejson | 15.8 | 30.1 |
| json | 14.8 | 20.5 |

#### canada.json

| Library | import, read() RSS (MiB) | loads() increase in RSS (MiB) |
|------------|----------------------------|---------------------------------|
| orjson | 17.2 | 22.1 |
| ujson | 17.4 | 18.3 |
| rapidjson | 18 | 23.5 |
| simplejson | 15.7 | 21.4 |
| json | 15.4 | 20.4 |

### Reproducing

The above was measured using Python 3.11.9 on Linux (amd64) with
orjson 3.10.6, ujson 5.10.0, python-rapidson 1.18, and simplejson 3.19.2.

The latency results can be reproduced using the `pybench` and `graph`
scripts. The memory results can be reproduced using the `pymem` script.
scripts.

## Questions

Expand Down Expand Up @@ -1226,7 +1174,8 @@ example using clang and LTO.

The project's own CI tests against `nightly-2024-09-25` and stable 1.72. It
is prudent to pin the nightly version because that channel can introduce
breaking changes.
breaking changes. There is a significant performance benefit to using
nightly.

orjson is tested for amd64 on Linux and cross-compiles for aarch64, arm7,
ppc64le, and s390x. It is tested for either aarch64 or amd64 on macOS and
Expand Down
4 changes: 4 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ fn main() {
println!("cargo:rustc-cfg=feature=\"optimize\"");
}

if let Some(true) = version_check::supports_feature("hint_assert_unchecked") {
println!("cargo:rustc-cfg=feature=\"assert_unchecked\"");
}

#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
if env::var("ORJSON_DISABLE_SIMD").is_err() {
// auto build unstable SIMD on nightly
Expand Down
2 changes: 1 addition & 1 deletion ci/azure-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ steps:
displayName: build dependencies
- script: python.exe -m pip install -r test\requirements.txt -r integration\requirements.txt
displayName: test dependencies
- script: maturin.exe build --release --features=no-panic,unstable-simd,yyjson --strip --interpreter $(interpreter) --target $(target)
- script: maturin.exe build --release --features=unstable-simd,yyjson --strip --interpreter $(interpreter) --target $(target)
displayName: build
env:
CFLAGS: "-Os -flto"
Expand Down
Loading

0 comments on commit 8d4e289

Please sign in to comment.