Skip to content

Performance difference Foundation JSON vs. PureSwiftJSON #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fabianfett opened this issue Mar 5, 2020 · 1 comment
Closed

Performance difference Foundation JSON vs. PureSwiftJSON #5

fabianfett opened this issue Mar 5, 2020 · 1 comment
Labels
area/performance Improvements to performance.

Comments

@fabianfett
Copy link
Member

swift 5.1.4 on Amazon Linux 2

Foundation.JSONCoding
-----------------------------
string, cold: 25724953 (ns)
string, warm: 370171 (ns)
json, cold: 25843952 (ns)
json, warm: 423885 (ns)
-----------------------------

PureSwiftJSONCoding
-----------------------------
string, cold: 23219984 (ns)
string, warm: 372525 (ns)
json, cold: 23525811 (ns)
json, warm: 390062 (ns)
-----------------------------

boot speedup: 8-10% (not linking Foundation, statically linking PureSwiftJSONCoding)
json warm speedup: 8% should be more with larger json payloads.

@fabianfett
Copy link
Member Author

Difference in linked Frameworks:

With Foundation
bash-4.2# ldd .build/release/SwiftAwsLambdaSample
	linux-vdso.so.1 (0x00007fff38d64000)
	libswiftGlibc.so => /usr/lib/swift/linux/libswiftGlibc.so (0x00007f0cedcfe000)
	libswiftCore.so => /usr/lib/swift/linux/libswiftCore.so (0x00007f0ced2f6000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f0ced0d8000)
	libutil.so.1 => /lib64/libutil.so.1 (0x00007f0ceced5000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f0ceccd1000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f0cec991000)
	libswiftDispatch.so => /usr/lib/swift/linux/libswiftDispatch.so (0x00007f0cedcc3000)
	libdispatch.so => /usr/lib/swift/linux/libdispatch.so (0x00007f0cedc61000)
	libBlocksRuntime.so => /usr/lib/swift/linux/libBlocksRuntime.so (0x00007f0cec78e000)
	libFoundation.so => /usr/lib/swift/linux/libFoundation.so (0x00007f0cebf12000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f0cebb90000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f0ceb97a000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f0ceb5cf000)
	libatomic.so.1 => /lib64/libatomic.so.1 (0x00007f0ceb3c7000)
	libicui18nswift.so.61 => /usr/lib/swift/linux/libicui18nswift.so.61 (0x00007f0ceaed3000)
	libicuucswift.so.61 => /usr/lib/swift/linux/libicuucswift.so.61 (0x00007f0ceaaed000)
	libicudataswift.so.61 => /usr/lib/swift/linux/libicudataswift.so.61 (0x00007f0ce8f48000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f0cedaed000)
	librt.so.1 => /lib64/librt.so.1 (0x00007f0ce8d40000)

Without Foundation
bash-4.2# ldd .build/release/SwiftAwsLambdaSample
	linux-vdso.so.1 (0x00007ffde178a000)
	libswiftGlibc.so => /usr/lib/swift/linux/libswiftGlibc.so (0x00007f1e6bccb000)
	libswiftCore.so => /usr/lib/swift/linux/libswiftCore.so (0x00007f1e6b2c3000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f1e6b0a5000)
	libutil.so.1 => /lib64/libutil.so.1 (0x00007f1e6aea2000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007f1e6ac9e000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f1e6a95e000)
	libswiftDispatch.so => /usr/lib/swift/linux/libswiftDispatch.so (0x00007f1e6bc90000)
	libdispatch.so => /usr/lib/swift/linux/libdispatch.so (0x00007f1e6bc2e000)
	libBlocksRuntime.so => /usr/lib/swift/linux/libBlocksRuntime.so (0x00007f1e6a75b000)
	libFoundation.so => /usr/lib/swift/linux/libFoundation.so (0x00007f1e69edf000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f1e69b5d000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f1e69947000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f1e6959c000)
	libatomic.so.1 => /lib64/libatomic.so.1 (0x00007f1e69394000)
	libicui18nswift.so.61 => /usr/lib/swift/linux/libicui18nswift.so.61 (0x00007f1e68ea0000)
	libicuucswift.so.61 => /usr/lib/swift/linux/libicuucswift.so.61 (0x00007f1e68aba000)
	libicudataswift.so.61 => /usr/lib/swift/linux/libicudataswift.so.61 (0x00007f1e66f15000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f1e6baba000)
	librt.so.1 => /lib64/librt.so.1 (0x00007f1e66d0d000)

It really is just on Framework difference. Foundation does not require more frameworks (than needed anyways) to be linked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/performance Improvements to performance.
Projects
None yet
Development

No branches or pull requests

2 participants