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 — Fix performance regression in FastThreadLocal microbenchmark. by buchgr · Pull Request #4417 · netty/netty

Conversation

@buchgr

@buchgr buchgr commented Oct 29, 2015

Copy link
Copy Markdown
Contributor

Fixes #4402.

Motivation:

As reported in #4402, the FastThreadLocalBenchmark shows that the JDK ThreadLocal
is actually faster than Netty's custom thread local implementation.

I was looking forward to doing some deep digging, but got disappointed :(.

Modifications:

The microbenchmark was not using FastThreadLocalThreads and would thus always hit the slow path.
I updated the JMH command line flags, so that FastThreadLocalThreads would be used.

Result:

FastThreadLocalBenchmark shows FastThreadLocal to be faster than JDK's ThreadLocal implementation,
by about 56% in this particular benchmark. Run on OSX El Capitan with OpenJDK 1.8u60.

Benchmark                                    Mode  Cnt      Score      Error  Units
FastThreadLocalBenchmark.fastThreadLocal    thrpt   20  55452.027 ±  725.713  ops/s
FastThreadLocalBenchmark.jdkThreadLocalGet  thrpt   20  35481.888 ± 1471.647  ops/s

Sorry, something went wrong.

Uh oh!

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

All reactions
@buchgr
Fix performance regression in FastThreadLocal microbenchmark. Fixes n…
d105746
…etty#4402

Motivation:

As reported in netty#4402, the FastThreadLocalBenchmark shows that the JDK ThreadLocal
is actually faster than Netty's custom thread local implementation.

I was looking forward to doing some deep digging, but got disappointed :(.

Modifications:

The microbenchmark was not using FastThreadLocalThreads and would thus always hit the slow path.
I updated the JMH command line flags, so that FastThreadLocalThreads would be used.

Result:

FastThreadLocalBenchmark shows FastThreadLocal to be faster than JDK's ThreadLocal implementation,
by about 56% in this particular benchmark. Run on OSX El Capitan with OpenJDK 1.8u60.

Benchmark                                    Mode  Cnt      Score      Error  Units
FastThreadLocalBenchmark.fastThreadLocal    thrpt   20  55452.027 ±  725.713  ops/s
FastThreadLocalBenchmark.jdkThreadLocalGet  thrpt   20  35481.888 ± 1471.647  ops/s
@normanmaurer normanmaurer self-assigned this Oct 29, 2015
@normanmaurer normanmaurer added this to the 4.0.33.Final milestone Oct 29, 2015
@normanmaurer normanmaurer added the defect label Oct 29, 2015
@buchgr

buchgr commented Oct 29, 2015

Copy link
Copy Markdown
Contributor Author

@normanmaurer @ninja- PTAL and give it a try yourself on your machines.

As a followup, it might make sense to actually fallback to JDK ThreadLocal for the slow path.

All reactions

Sorry, something went wrong.

Uh oh!

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

@normanmaurer

normanmaurer commented Oct 29, 2015

Copy link
Copy Markdown
Member

@buchgr thanks, you beat me here :)

Cherry-picked into 4.0 (e12613a), 4.1 (c936461) and master (2c69dcc)

All reactions

Sorry, something went wrong.

Uh oh!

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

@normanmaurer normanmaurer closed this Oct 29, 2015
@normanmaurer

normanmaurer commented Oct 29, 2015

Copy link
Copy Markdown
Member

@buchgr also yes we should improve the "slow-path". Want to work on a PR (hint) ;) ?

All reactions

Sorry, something went wrong.

Uh oh!

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

@buchgr

buchgr commented Oct 29, 2015

Copy link
Copy Markdown
Contributor Author

@normanmaurer maybe, if I find time :). I ll open an issue. I am insanely busy at the moment (working on my thesis) and only got to installing Netty today (1 issue reported, 1 fixed #whoopwhoop).

All reactions

Sorry, something went wrong.

Uh oh!

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

@normanmaurer

normanmaurer commented Oct 29, 2015

Copy link
Copy Markdown
Member

@buchgr ok slacker ;) Good luck with it!

I will look into it.

All reactions

Sorry, something went wrong.

Uh oh!

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

@buchgr buchgr mentioned this pull request Oct 29, 2015
Improve performance of FastThreadLocal slow path #4418
Closed
@ninja- ninja- mentioned this pull request Oct 29, 2015
Reduce thread context check overhead #4412
Closed
13 tasks done
@ninja-

ninja- commented Oct 29, 2015

Copy link
Copy Markdown

Benchmark Mode Cnt Score Error Units
FastThreadLocalBenchmark.fastThreadLocal thrpt 20 55452.027 ± 725.713 ops/s
FastThreadLocalBenchmark.jdkThreadLocalGet thrpt 20 35481.888 ± 1471.647 ops/s

weird. jdk's thread local looks really, really solid these days. what's wrong with it?

All reactions

Sorry, something went wrong.

Uh oh!

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

@zsxwing zsxwing mentioned this pull request Aug 30, 2016
[SPARK-17314][Core]Use Netty's DefaultThreadFactory to enable its fast ThreadLocal impl apache/spark#14879
Closed
asfgit pushed a commit to apache/spark that referenced this pull request Aug 30, 2016
@zsxwing
[SPARK-17314][CORE] Use Netty's DefaultThreadFactory to enable its fa…
02ac379
…st ThreadLocal impl

## What changes were proposed in this pull request?

When a thread is a Netty's FastThreadLocalThread, Netty will use its fast ThreadLocal implementation. It has a better performance than JDK's (See the benchmark results in netty/netty#4417, note: it's not a fix to Netty's FastThreadLocal. It just fixed an issue in Netty's benchmark codes)

This PR just changed the ThreadFactory to Netty's DefaultThreadFactory which will use FastThreadLocalThread. There is also a minor change to the thread names. See https://github.com/netty/netty/blob/netty-4.0.22.Final/common/src/main/java/io/netty/util/concurrent/DefaultThreadFactory.java#L94

## How was this patch tested?

Author: Shixiong Zhu <[email protected]>

Closes #14879 from zsxwing/netty-thread.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

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

Assignees

@normanmaurer normanmaurer

Labels

defect

Projects

None yet

Milestone

4.0.33.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

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

4 participants

@buchgr @normanmaurer @ninja- @netkins
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 01402775 — 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.