GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Cache JsonProvider.provider() result as per javadoc recommendation by gbloisi · Pull Request #78 · javaee/jsonp

This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Conversation

@gbloisi

@gbloisi gbloisi commented Mar 18, 2018

Copy link
Copy Markdown

I got through this because I found a performance hostpot in calling Json methods (about 500 microsec per call on a i5)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rogersnm reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@gbloisi
Cache JsonProvider.provider() as per javadoc recommendation
1613d0f
@rogersnm

rogersnm commented Apr 6, 2018

Copy link
Copy Markdown

+1, I'm serialising a large object and it takes about 2000ms on my machine currently. Switching to this implementation drops it down to 50ms.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@keilw

keilw commented Apr 6, 2018

Copy link
Copy Markdown
Member

See jakartaee/jsonp-api#80 it seems there already is a similar PR in Jakarta EE. I doubt that this repository results in any new updates or releases.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@m0mus
m0mus requested review from bravehorsie and lukasj April 6, 2018 15:49
@m0mus

m0mus commented Apr 6, 2018

Copy link
Copy Markdown
Member

@lukasj @bravehorsie Recently there were some similar PRs in different projects. I am not 100% convinced that it's needed. Folks, I want you to review it before letting it go.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bravehorsie
bravehorsie suggested changes Apr 6, 2018
View reviewed changes
Comment thread api/src/main/java/javax/json/Json.java
*/
public final class Json {

static final JsonProvider PROVIDER = JsonProvider.provider();

@bravehorsie bravehorsie Apr 6, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently this would actually decrease performance with default implementation if JsonProvider is cached by client application (as it is supposed to). See

jsonp/impl/src/main/java/org/glassfish/json/JsonProviderImpl.java

Line 69 in 1341356

private final BufferPool bufferPool = new BufferPoolImpl();

When JsonProvider instance is cached like this buffer pool exists only once. Because it uses ConcurrentLinkedQueue it will decrease performance in multithreaded environment because of synchronization.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@keilw keilw Apr 9, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I certainly see dangers making it final. That way for the lifetime of the Json class in a particular JVM it would remain the same even if the underlying provider may change (less likely without OSGi but possible for some implementations)
Keeping a static cache, maybe, as long as there's at least a protected or similar way to reset it, see how we did in JSR 363 with ServiceProvider or CDI.
I am not convinced we still need this in Java EE 8, maybe leave to a future (Jakarta EE) version of JSON-P?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
lukasj
lukasj suggested changes Apr 6, 2018
View reviewed changes

@lukasj lukasj left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comments as in jakartaee/jsonp-api#80 apply here

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jeck81
jeck81 approved these changes May 15, 2018
View reviewed changes

This branch has not been deployed

No deployments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

4 more reviewers
@keilw keilw keilw left review comments
@lukasj lukasj lukasj requested changes
@bravehorsie bravehorsie bravehorsie requested changes
@jeck81 jeck81 jeck81 approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

7 participants

@gbloisi @rogersnm @keilw @m0mus @lukasj @bravehorsie @jeck81
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.