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
Consume less memory #159
base: master
Are you sure you want to change the base?
Consume less memory #159
Conversation
…side of JsonIterator
Codecov Report
@@ Coverage Diff @@
## master #159 +/- ##
========================================
Coverage ? 68.5%
========================================
Files ? 107
Lines ? 7354
Branches ? 1388
========================================
Hits ? 5038
Misses ? 1869
Partials ? 447
Continue to review full report at Codecov.
|
what is your usage scenario to concern the memory usage so much? |
I can't see any reason to bloat memory. When we can use 256 bytes instead of 1K, why don't do so? |
Do you have memory benchmark to prove this change worthwhile? It looks non substantial to me. |
Output differs a bit between invocations. In general, I've saved about 20 KB. |
the saving is not proportional to the length of input. 20kb constant memory saving is not worth it. |
I's a bit philosophical decision: when I can free some memory without affecting performance, I do it. |
@Miha-x64 Totally agreed. Specially if we use jsoniter where we have strict hardware constraints, like AWS Lambda functions. |
I would say that this PR proposes a trade off which save memory by spending more CPU cycles in runtime. Also, worst cases in case of malformed input are getting more worse here. As example rethowing of exception can take the same time as a small message parsing. See more info here: https://shipilev.net/blog/2014/exceptional-performance/ |
It seems like a good point. I'd rather consume a bit more memory if we have
any sort of memory penalty.
…On Thu, Apr 18, 2019 at 5:01 PM Andriy Plokhotnyuk ***@***.***> wrote:
I would say that this PR proposes a trade off which save memory by
spending more CPU cycles in runtime.
Also, worst cases in case of malformed input are getting more worse here.
As example rethowing of exception can take the same time as a small message
parsing. See more info here:
https://shipilev.net/blog/2014/exceptional-performance/
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#159 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAD7NUCBI4UNZJVHUCE3KULPRAMDLANCNFSM4ETDY65A>
.
--
/* Miere L. Teixeira */
|
ops: CPU performance penalty.
…On Thu, Apr 18, 2019 at 5:11 PM Miere Teixeira ***@***.***> wrote:
It seems like a good point. I'd rather consume a bit more memory if we
have any sort of memory penalty.
On Thu, Apr 18, 2019 at 5:01 PM Andriy Plokhotnyuk <
***@***.***> wrote:
> I would say that this PR proposes a trade off which save memory by
> spending more CPU cycles in runtime.
>
> Also, worst cases in case of malformed input are getting more worse here.
> As example rethowing of exception can take the same time as a small message
> parsing. See more info here:
> https://shipilev.net/blog/2014/exceptional-performance/
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <#159 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAD7NUCBI4UNZJVHUCE3KULPRAMDLANCNFSM4ETDY65A>
> .
>
--
/* Miere L. Teixeira */
--
/* Miere L. Teixeira */
|
…ymbols" & stop wasting CPU cycles
# Conflicts: # src/main/java/com/jsoniter/JsonIterator.java
Reduced memory consumption:
— removed unused
BitInteger
constants inIterImpl
;— changed
IterImplNumber.intDigits
,IterImplNumber.floatDigits
type fromint[]
tobyte[]
;— changed
IterImplString.hexDigits
type fromint[]
tobyte[]
and shifted it by 48 ('0'
);— using
byte
constants instead ofValueType
inJsonIterator
, using ownbyte[]
dictionary instead ofValueType[]
.