olabusayoT commented on code in PR #1712:
URL: https://github.com/apache/daffodil/pull/1712#discussion_r3753270106


##########
daffodil-core/src/main/scala/org/apache/daffodil/lib/xml/Namespaces.scala:
##########
@@ -42,15 +42,39 @@ object NS extends UniquenessCache[URI, NS] {
     super.apply(uri)
   }
 
+  /**
+   * Fast path for repeated raw namespace strings (e.g. resolving next-elements
+   * during unparse, where the same handful of namespace URI strings recur once
+   * per element in a document). The uniqueness cache above is a
+   * ReentrantReadWriteLock-guarded WeakHashMap keyed by URI, so even a cache
+   * hit there requires first parsing the string via URI.create and then taking
+   * a lock - fine for schema-compile-time use, but real per-call overhead on a
+   * per-element hot path. This map memoizes by the raw string itself, so a
+   * previously-seen string never reaches URI.create or the lock at all.

Review Comment:
   There was no discernable difference between UniquenessCache and 
ConcurrentHashMap implementation so I went with the UniquenessCache option. 
Looks like the URI.create was the overhead.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to