You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fory.apache.org by "ayush00git (via GitHub)" <gi...@apache.org> on 2026/03/02 18:50:18 UTC

[I] [BUG][] GO: //go:inline pragmas are no-ops — hot-path functions not being inlined [fory]

ayush00git opened a new issue, #3446:
URL: https://github.com/apache/fory/issues/3446

   ### Search before asking
   
   - [x] I had searched in the [issues](https://github.com/apache/fory/issues) and found no similar issues.
   
   
   ### Version
   
   Current
   
   ### Component(s)
   
   Go
   
   ### Minimal reproduce step
   
   Run `go build -gcflags='-m -m'`
   Output - 
   ```bash
   buffer.go:71:  cannot inline (*ByteBuffer).WriteByte:   cost 86 > budget 80
   buffer.go:86:  cannot inline (*ByteBuffer).WriteInt8:   cost 85 > budget 80
   buffer.go:114: cannot inline (*ByteBuffer).WriteUint32: cost 85 > budget 80
   buffer.go:121: cannot inline (*ByteBuffer).WriteInt32:  cost 86 > budget 80
   buffer.go:199: cannot inline (*ByteBuffer).ReadByte:    cost 94 > budget 80
   buffer.go:251: cannot inline (*ByteBuffer).ReadUint32:  cost 96 > budget 80
   buffer.go:264: cannot inline (*ByteBuffer).ReadUint64:  cost 96 > budget 80
   ```
   
   ### What did you expect to see?
   
   The budget if exceeds then only the error should come. Otherwise not
   
   ### What did you see instead?
   
   .
   
   ### Anything Else?
   
   .
   
   ### Are you willing to submit a PR?
   
   - [x] I'm willing to submit a PR!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [I] [BUG][GO]: //go:inline pragmas are no-ops — hot-path functions not being inlined [fory]

Posted by "ayush00git (via GitHub)" <gi...@apache.org>.
ayush00git commented on issue #3446:
URL: https://github.com/apache/fory/issues/3446#issuecomment-3988720372

   Removing `//go:noinline` from `growSlow()` does fix the write path, drops from cost 85 → 75, now under budget. However, the read path functions are unaffected because their cost comes from the inline `BufferOutOfBoundError()` construction, not from grow(). We still need to move the error construction to a `//go:noinline` helper to fix those.
   
   Also, the `//go:inline` comments throughout the file can be removed — the` gc` compiler doesn't recognize `//go:inline` as a directive. It automatically inlines any function with cost under 80.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [I] [BUG][GO]: //go:inline pragmas are no-ops — hot-path functions not being inlined [fory]

Posted by "ayush00git (via GitHub)" <gi...@apache.org>.
ayush00git commented on issue #3446:
URL: https://github.com/apache/fory/issues/3446#issuecomment-3999363478

   Hii @chaokunyang 
   I want to start fixing this bug, pls give #3374 a review. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [I] [BUG][] GO: //go:inline pragmas are no-ops — hot-path functions not being inlined [fory]

Posted by "ayush00git (via GitHub)" <gi...@apache.org>.
ayush00git commented on issue #3446:
URL: https://github.com/apache/fory/issues/3446#issuecomment-3986265350

   Hey @chaokunyang 
   Have a look at the issue and let me know is it right to begin ?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [I] [BUG][GO]: //go:inline pragmas are no-ops — hot-path functions not being inlined [fory]

Posted by "ayush00git (via GitHub)" <gi...@apache.org>.
ayush00git commented on issue #3446:
URL: https://github.com/apache/fory/issues/3446#issuecomment-3988725484

   Here are the outputs after i removed the `//go:noinline` from `growSlow()` - 
   
   ``` bash
   ./buffer.go:49:6: can inline (*ByteBuffer).growSlow with cost 47 as: method(*ByteBuffer) func(int) { needed := b.writerIndex + n; if needed <= cap(b.data) { b.data = b.data[:cap(b.data)] } else { newCap := 2 * needed; newBuf := make([]byte, newCap); copy(newBuf, b.data[:b.writerIndex]); b.data = newBuf } }
   ./buffer.go:40:6: can inline (*ByteBuffer).grow with cost 60 as: method(*ByteBuffer) func(int) { if b.writerIndex + n <= len(b.data) { return  }; (*ByteBuffer).growSlow(b, n) }
   ./buffer.go:85:6: can inline (*ByteBuffer).WriteInt8 with cost 75 as: method(*ByteBuffer) func(int8) { (*ByteBuffer).grow(b, 1); b.data[b.writerIndex] = byte(value); b.writerIndex++ }
   ./buffer.go:92:6: can inline (*ByteBuffer).WriteUint8 with cost 74 as: method(*ByteBuffer) func(uint8) { (*ByteBuffer).grow(b, 1); b.data[b.writerIndex] = value; b.writerIndex++ }
   ./buffer.go:211:6: cannot inline (*ByteBuffer).ReadInt8: function too complex: cost 95 exceeds budget 80
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [I] [BUG][GO]: //go:inline pragmas are no-ops — hot-path functions not being inlined [fory]

Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang closed issue #3446: [BUG][GO]: //go:inline pragmas are no-ops — hot-path functions not being inlined
URL: https://github.com/apache/fory/issues/3446


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [I] [BUG][GO]: //go:inline pragmas are no-ops — hot-path functions not being inlined [fory]

Posted by "ayush00git (via GitHub)" <gi...@apache.org>.
ayush00git commented on issue #3446:
URL: https://github.com/apache/fory/issues/3446#issuecomment-3998235772

   Hii @chaokunyang 
   I want to start fixing this bug, pls give #3374 a review. 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [I] [BUG][GO]: //go:inline pragmas are no-ops — hot-path functions not being inlined [fory]

Posted by "ayush00git (via GitHub)" <gi...@apache.org>.
ayush00git commented on issue #3446:
URL: https://github.com/apache/fory/issues/3446#issuecomment-3988911430

   Adding `//go:noinline` to all error constructors should fix the read path.
   But before raising a PR could you adress #3374 as it may cause merge conflicts


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [I] [BUG][GO]: //go:inline pragmas are no-ops — hot-path functions not being inlined [fory]

Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang commented on issue #3446:
URL: https://github.com/apache/fory/issues/3446#issuecomment-3988801828

   add `//go:noinline` to `BufferOutOfBoundError` and all similair func in error.go. And would be better to check whole fory go to mark  `//go:noinline`  for all cold path


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [I] [BUG][GO]: //go:inline pragmas are no-ops — hot-path functions not being inlined [fory]

Posted by "ayush00git (via GitHub)" <gi...@apache.org>.
ayush00git commented on issue #3446:
URL: https://github.com/apache/fory/issues/3446#issuecomment-3988809003

   > add `//go:noinline` to `BufferOutOfBoundError` and all similair func in error.go. And would be better to check whole fory go to mark `//go:noinline` for all cold path
   
   I'll try with that, but is there any point to still keep `//go:inline` ? I think I should remove it as well from the whole file ? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [I] [BUG][GO]: //go:inline pragmas are no-ops — hot-path functions not being inlined [fory]

Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang commented on issue #3446:
URL: https://github.com/apache/fory/issues/3446#issuecomment-3988807381

   I was wrong, the slow patrh should be annotated with `//go:noinline`. Please check carefully whether it's other issue. And `//go:inline` should be removed


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org


Re: [I] [BUG][GO]: //go:inline pragmas are no-ops — hot-path functions not being inlined [fory]

Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang commented on issue #3446:
URL: https://github.com/apache/fory/issues/3446#issuecomment-3988314889

   I think remove `//go:noinline` from growSlow would be enough. Could you check whether it will work?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org