You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by "Cole-Greer (via GitHub)" <gi...@apache.org> on 2026/03/24 00:09:57 UTC

[PR] Optimize no-GValue fast path in P.setValue() [tinkerpop]

Cole-Greer opened a new pull request, #3339:
URL: https://github.com/apache/tinkerpop/pull/3339

   https://issues.apache.org/jira/browse/TINKERPOP-3231
   
   As of 3.8.0, `P.setValue()` must process incoming collections to separate variables and literals. This can add significant overhead in the case of very large collections. 3.8.0 contained a "fast happy path" for the common case where no GValues are present, although this was gated by a GValue check utilizing Java's stream() API. This PR replaces that check with a simple for-loop check which in testing cuts the latency in half.
   
   Mentioned in the JIRA but not included in this PR is optimizations to `getValue()`, which has already been covered by https://github.com/apache/tinkerpop/commit/b2816c5669970adbcd451493f057078ff58f17d5.
   
   ### Benchmark Results
   
   |                        | 3.8.0    | 3.8.1-SNAPSHOT |
   |------------------------|----------|----------------|
   | setValue([1M doubles]) | 3.63ms   | 1.74 ms        |
   | setValue([1M GValues]) | 31.01 ms | 28.12 ms       |
   | setValue([1M Mixed])   | 18.04 ms | 19.03 ms       |
   | getValue([1M doubles]) | 3.05 ms  | 2.74 ms              |
   | getValue([1M GValues]) | 13.04 ms | 12.74 ms              |
   | getValue([1M Mixed])   | 7.52 ms  | 6.38 ms              |
   
   VOTE +1


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

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


Re: [PR] Optimize no-GValue fast path in P.setValue() [tinkerpop]

Posted by "Cole-Greer (via GitHub)" <gi...@apache.org>.
Cole-Greer closed pull request #3339: Optimize no-GValue fast path in P.setValue()
URL: https://github.com/apache/tinkerpop/pull/3339


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

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


Re: [PR] Optimize no-GValue fast path in P.setValue() [tinkerpop]

Posted by "xiazcy (via GitHub)" <gi...@apache.org>.
xiazcy commented on code in PR #3339:
URL: https://github.com/apache/tinkerpop/pull/3339#discussion_r2978439805


##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/P.java:
##########
@@ -127,10 +127,16 @@ public void setValue(final V value) {
             isCollection = false;
         } else if (value instanceof Collection) {
             isCollection = true;
-            if (((Collection<?>) value).stream().anyMatch(v -> v instanceof GValue)) {
+            final Collection<V> vCollection = (Collection<V>) value;
+
+            // fast path: if no GValues in the collection, use collection directly
+            if (!containsGValue(vCollection)) {
+                if (value instanceof BulkSet) {
+                    this.literals = vCollection;
+                }

Review Comment:
   ```suggestion
                   this.literals = vCollection;
   ```
   Shouldn't this just be the `else` case before, regardless of it's `BulkSet` or not? I.e. it looks like the non-BulkSet cases are being left out. 



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

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