Skip to content

Need a mechanism to break up long methods without call overhead #69699

Answered by jaredpar
CodeSetting asked this question in Ideas
Discussion options

You must be logged in to vote

However, for the limited case of a single-reference, local function, I see little risk.

I disagree with the little risk part of this assessment. @CyrusNajmabadi has outlined many of the risks but the ones that always come to mind for me are:

Inlining can reduce optimizations.

The JIT operates on a series of heuristics and inlining methods can trigger heuristics that cause the JIT to generate less efficient code. A classic example of that problem is throw. Historically the JIT does not optimize methods that use throw as good as it does methods that don't. In high perf code bases it's a common pattern to use throw helper methods to alleviate this problem

void M(string arg) {
  if (arg is n…

Replies: 5 comments 16 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@CyrusNajmabadi
Comment options

Comment options

You must be logged in to vote
1 reply
@CyrusNajmabadi
Comment options

Comment options

You must be logged in to vote
11 replies
@CyrusNajmabadi
Comment options

@CodeSetting
Comment options

@CyrusNajmabadi
Comment options

@CodeSetting
Comment options

@CyrusNajmabadi
Comment options

Comment options

You must be logged in to vote
3 replies
@CodeSetting
Comment options

@CyrusNajmabadi
Comment options

@CyrusNajmabadi
Comment options

Answer selected by sharwell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
3 participants