Skip to content

Shorter sleep while waiting for encoder/decoder #167

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

Merged
merged 1 commit into from
Sep 14, 2017

Conversation

olegshaldybin
Copy link
Contributor

If the client is using the same jsoniter config with multiple goroutines
it's very likely that few initial operations will encounter a placeholder
encoder/decoder while the real one is being created by another
goroutine. Having a full second sleep seems too conservative, since
encoder/decoder will be created in a very short time. This is very easy
to reproduce in any real environment with a few concurrent requests of
the same type. A few initial requests will have 1s+ response time.

Changing to 10ms should smooth out marshal/unmarshal times for these
initial concurrent requests.

If the client is using the same jsoniter config with multiple goroutines
it's very likely that few initial operations will encounter a placeholder
encoder/decoder while the real one is being created by another
goroutine. Having a full second sleep seems too conservative, since
encoder/decoder will be created in a very short time. This is very easy
to reproduce in any real environment with a few concurrent requests of
the same type. A few initial requests will have 1s+ response time.

Changing to 10ms should smooth out marshal/unmarshal times for these
initial concurrent requests.
@codecov
Copy link

codecov bot commented Sep 14, 2017

Codecov Report

Merging #167 into master will not change coverage.
The diff coverage is 25%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master    #167   +/-   ##
======================================
  Coverage    84.5%   84.5%           
======================================
  Files          41      41           
  Lines        5195    5195           
======================================
  Hits         4390    4390           
  Misses        641     641           
  Partials      164     164
Impacted Files Coverage Δ
feature_reflect.go 77.58% <25%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 90574c5...34fbec7. Read the comment docs.

@taowen taowen merged commit 0fdf883 into json-iterator:master Sep 14, 2017
zhenzou pushed a commit to zhenzou/jsoniter that referenced this pull request Feb 2, 2022
Shorter sleep while waiting for encoder/decoder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants