IABTechLab / iabgpp-java

Apache License 2.0
11 stars 12 forks source link

lazy decoding #34

Closed chuff closed 3 months ago

Net-burst commented 5 months ago

I took the liberty to do a very simple performance comparison between the master and this PR. The test was extremely simple and mostly directed toward measuring the decoding performance and the performance of pulling out the EU TCF string out of GPP string. The test was done using the JMH.

    @Benchmark
    public void decodeOnly(Blackhole blackhole, ConsentString consentString) throws DecodingException, EncodingException {
        blackhole.consume(new GppModel(consentString.consent));
    }

    @Benchmark
    public void decodeAndGet(Blackhole blackhole, ConsentString consentString) throws DecodingException, EncodingException {
        GppModel gppModel = new GppModel(consentString.consent);
        blackhole.consume(gppModel.encodeSection(TcfEuV2.ID));
    }

I used 2 different consent strings for this: the one from the Readme.md and a random real GPP string generated by the real CMP in Europe. I'll call those short and long GPP string accordingly.

The current master

Short GPP
Benchmark                     Mode  Cnt       Score     Error  Units
GppLibPerfTest.decodeAndGet  thrpt   25   55050.257 ± 798.702  ops/s
GppLibPerfTest.decodeOnly    thrpt   25  104209.384 ± 690.231  ops/s

Long GPP
Benchmark                     Mode  Cnt     Score   Error  Units
GppLibPerfTest.decodeAndGet  thrpt   25   312.324 ± 0.579  ops/s
GppLibPerfTest.decodeOnly    thrpt   25  2649.314 ± 6.534  ops/s

Please notice the huge performance degradation when transitioning from the example GPP string to a real-world GPP string.

This PR

Short GPP
Benchmark                     Mode  Cnt          Score        Error  Units
GppLibPerfTest.decodeAndGet  thrpt   25     607814.864 ±   1748.729  ops/s
GppLibPerfTest.decodeOnly    thrpt   25  269170680.844 ± 536131.656  ops/s

Long GPP
Benchmark                     Mode  Cnt          Score        Error  Units
GppLibPerfTest.decodeAndGet  thrpt   25     587291.468 ±   1715.360  ops/s
GppLibPerfTest.decodeOnly    thrpt   25  268889768.896 ± 477279.182  ops/s

Pure decoding is meaningless now, as nothing happens before anything is requested from the object. However, the TCF EU extraction performance is much better. And apart from the huge overall performance improvement, the performance degradation with real-world GPP string is gone.

The test was done on an Apple Macbook M2 Pro. It's not scientific in any way though and was done purely for comparison.

ym-corey commented 4 months ago

Are there any plans to release this sometime soon?

Net-burst commented 3 months ago

Any updates on this one? Is there a plan to merge it anytime soon?