-
Notifications
You must be signed in to change notification settings - Fork 13
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
CPU and Memory Optimizations #56
base: master
Are you sure you want to change the base?
Conversation
This looks great 👍 |
5e4b971
to
02f53c4
Compare
@iabmayank @chuff can you please take a look at this? |
8bac901
to
c30373e
Compare
@iabmayank @chuff i have rebased off of the most recent master |
@yuzawa-san thank you for submitting this, we will be reviewing these in the working group |
@yuzawa-san |
@chuff removed i would like to try adding it again in the future in a separate pr since i feel it is quite important that contributors have the ability to easily generate benchmarks. just curious, why did you favor removing it? |
I found the CPU and Memory in the decode hot path is very high, so I did some light refactoring to alleviate this.
List<Boolean>
. This is a lot smaller that theArrayList<Boolean>
+
usages since that is optimized (in JDK8) to a StringBuilder. if it used the char constant it appears to have to convert those chars to Strings each time. however in later JDK's this is not needed.microbenchmark results:
seems to be around 6x faster than the last released version and uses only about 97% less memory.
ad-hoc benchmark code against https://github.com/InteractiveAdvertisingBureau/iabtcf-java (partially ported into JMH)
benchmarked using async-profiler
asprof -d 20 -e cpu,alloc -f ~/Desktop/dump16.jfr TcfBench
Flame Charts:
memory before:
memory after (note how TCString parse was small teal sliver in the before graph, but the iab-gpp portion has shrank so much that the TCString parse is now a larger percentage of the icicle chart):
cpu before:
cpu after:
Future Ideas (not in PR). I'll likely open issues to discuss:
List<Integer>
is still a little bulky in the charts above. I was thinking of maybe making a specialty class backed by int[] like https://github.com/InteractiveAdvertisingBureau/iabtcf-java/blob/master/iabtcf-decoder/src/main/java/com/iabtcf/utils/IntIterable.java but that would likely break API stabilityfixes #25
supersedes #45