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

[PR] Inline MStack operations and allow sizing stacks up front [daffodil]

olabusayoT opened a new pull request, #1739:
URL: https://github.com/apache/daffodil/pull/1739

   MStack's @specialized annotation has no effect under Scala 3, so push, pop, setTop and top on the Boolean, Int, Long and reference stacks boxed the element and went through ScalaRunTime's type-dispatching array_update and array_apply. Make push, pop, setTop, top and bottom inline, so each call site is expanded with the stack's concrete element type and compiles to direct array loads and stores.
   
   Stacks take an initialSize, 32 by default, so a caller that knows its depth can avoid growing the array. A diagnostic, off unless MStack.trackMaxSizeReached is set, records the deepest a stack has grown, for choosing a size. TestMStack covers the operations, growth and copyFrom.
   
   DAFFODIL-3065


-- 
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@daffodil.apache.org

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


Re: [PR] Inline MStack operations and allow sizing stacks up front [daffodil]

Posted by "stevedlawrence (via GitHub)" <gi...@apache.org>.
stevedlawrence commented on PR #1739:
URL: https://github.com/apache/daffodil/pull/1739#issuecomment-5996671448

   Also, are there places you've identified that could make use of the initialSize capability, or is that planned for future PRs, maybe after some testing with the `trackMaxSizedReached` feature?


-- 
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@daffodil.apache.org

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


Re: [PR] Inline MStack operations and allow sizing stacks up front [daffodil]

Posted by "olabusayoT (via GitHub)" <gi...@apache.org>.
olabusayoT merged PR #1739:
URL: https://github.com/apache/daffodil/pull/1739


-- 
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@daffodil.apache.org

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


Re: [PR] Inline MStack operations and allow sizing stacks up front [daffodil]

Posted by "stevedlawrence (via GitHub)" <gi...@apache.org>.
stevedlawrence commented on code in PR #1739:
URL: https://github.com/apache/daffodil/pull/1739#discussion_r4184324910


##########
daffodil-core/src/main/scala/org/apache/daffodil/lib/util/MStack.scala:
##########
@@ -24,6 +24,12 @@ import Maybe.*
 object MStack {
   final case class Mark(val v: Int) extends AnyVal
   val nullMark = Mark(0)
+
+  /**
+   * Off by default: growing past initialSize isn't itself wrong, so paying
+   * this bookkeeping cost on every push isn't worth it normally.
+   */
+  final val trackMaxSizeReached: Boolean = false

Review Comment:
   We might consider making this inline too? I think scala will compile out final val's also, inline is a bit more explicit that we want the if-conditions compiled out based on this value.



-- 
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@daffodil.apache.org

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