You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@johnzon.apache.org by Mark Struberg <st...@yahoo.de.INVALID> on 2019/06/26 09:49:28 UTC

optimisations with buffer initialisation

hi folks!

we have some potential enhancements in our init routines which could lead to slightly less resource consumption.

static class JsonProviderDelegate extends JsonProvider {
    private final BufferStrategy.BufferProvider<char[]> bufferProvider =
        BufferStrategyFactory.valueOf(System.getProperty("johnzon.global-char-provider.strategy", "QUEUE"))
            .newCharProvider(Integer.getInteger("org.apache.johnzon.default-char-provider.length", 1024));

    private final JsonReaderFactory readerFactory = new JsonReaderFactoryImpl(null);
    private final JsonParserFactory parserFactory = new JsonParserFactoryImpl(null);
    private final JsonGeneratorFactory generatorFactory = new JsonGeneratorFactoryImpl(null);
    private final JsonWriterFactory writerFactory = new JsonWriterFactoryImpl(null);
    private final JsonBuilderFactoryImpl builderFactory = new JsonBuilderFactoryImpl(null, bufferProvider);

It seems we create multiple different BufferStragegy instances.
They should essentially all either be lazily created or reuse the same default strategy or even BufferProvider, isn't?

LieGrue,
strub


Re: optimisations with buffer initialisation

Posted by Romain Manni-Bucau <rm...@gmail.com>.
+1

Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>


Le mer. 26 juin 2019 à 11:49, Mark Struberg <st...@yahoo.de.invalid> a
écrit :

> hi folks!
>
> we have some potential enhancements in our init routines which could lead
> to slightly less resource consumption.
>
> static class JsonProviderDelegate extends JsonProvider {
>     private final BufferStrategy.BufferProvider<char[]> bufferProvider =
>
> BufferStrategyFactory.valueOf(System.getProperty("johnzon.global-char-provider.strategy",
> "QUEUE"))
>
> .newCharProvider(Integer.getInteger("org.apache.johnzon.default-char-provider.length",
> 1024));
>
>     private final JsonReaderFactory readerFactory = new
> JsonReaderFactoryImpl(null);
>     private final JsonParserFactory parserFactory = new
> JsonParserFactoryImpl(null);
>     private final JsonGeneratorFactory generatorFactory = new
> JsonGeneratorFactoryImpl(null);
>     private final JsonWriterFactory writerFactory = new
> JsonWriterFactoryImpl(null);
>     private final JsonBuilderFactoryImpl builderFactory = new
> JsonBuilderFactoryImpl(null, bufferProvider);
>
> It seems we create multiple different BufferStragegy instances.
> They should essentially all either be lazily created or reuse the same
> default strategy or even BufferProvider, isn't?
>
> LieGrue,
> strub
>
>