Skip to content

Commit

Permalink
perf(java): inline same element invoke in jit (#1851)
Browse files Browse the repository at this point in the history
<!--
**Thanks for contributing to Fury.**

**If this is your first time opening a PR on fury, you can refer to
[CONTRIBUTING.md](https://github.com/apache/fury/blob/main/CONTRIBUTING.md).**

Contribution Checklist

- The **Apache Fury (incubating)** community has restrictions on the
naming of pr titles. You can also find instructions in
[CONTRIBUTING.md](https://github.com/apache/fury/blob/main/CONTRIBUTING.md).

- Fury has a strong focus on performance. If the PR you submit will have
an impact on performance, please benchmark it first and provide the
benchmark result here.
-->

## What does this PR do?

<!-- Describe the purpose of this PR. -->

## Related issues

<!--
Is there any related issue? Please attach here.

- #xxxx0
- #xxxx1
- #xxxx2
-->

## Does this PR introduce any user-facing change?

<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fury/issues/new/choose) describing the
need to do so and update the document if necessary.
-->

- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?

## Benchmark

<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->
  • Loading branch information
chaokunyang authored Sep 24, 2024
1 parent 89a8d01 commit 9025947
Showing 1 changed file with 18 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1278,18 +1278,16 @@ protected Expression readCollectionCodegen(
readBuilder.add(
readContainerElements(
elementType, true, elemSerializer, null, buffer, collection, size));
Set<Expression> cutPoint = ofHashSet(buffer, collection, size);
if (maybeDecl) { // For `isDeclType`
cutPoint.add(flags);
}
Expression sameElementClassRead =
invokeGenerated(ctx, cutPoint, readBuilder, "sameElementClassRead", false);
// Same element class read end
action =
new If(
sameElementClass,
sameElementClassRead,
readContainerElements(elementType, true, null, null, buffer, collection, size));
Set<Expression> cutPoint = ofHashSet(buffer, collection, size);
Expression differentElemTypeRead =
invokeGenerated(
ctx,
cutPoint,
readContainerElements(elementType, true, null, null, buffer, collection, size),
"differentTypeElemsRead",
false);
action = new If(sameElementClass, readBuilder, differentElemTypeRead);
} else {
Literal hasNullFlag = Literal.ofInt(CollectionFlags.HAS_NULL);
Expression hasNull = eq(new BitAnd(flags, hasNullFlag), hasNullFlag, "hasNull");
Expand All @@ -1299,18 +1297,16 @@ protected Expression readCollectionCodegen(
readBuilder.add(
readContainerElements(
elementType, false, elemSerializer, hasNull, buffer, collection, size));
Set<Expression> cutPoint = ofHashSet(buffer, collection, size, hasNull);
if (maybeDecl) { // For `isDeclType`
cutPoint.add(flags);
}
// Same element class read end
Expression sameElementClassRead =
invokeGenerated(ctx, cutPoint, readBuilder, "sameElementClassRead", false);
action =
new If(
sameElementClass,
sameElementClassRead,
readContainerElements(elementType, false, null, hasNull, buffer, collection, size));
Set<Expression> cutPoint = ofHashSet(buffer, collection, size, hasNull);
Expression differentTypeElemsRead =
invokeGenerated(
ctx,
cutPoint,
readContainerElements(elementType, false, null, hasNull, buffer, collection, size),
"differentTypeElemsRead",
false);
action = new If(sameElementClass, readBuilder, differentTypeElemsRead);
}
builder.add(action);
}
Expand Down

0 comments on commit 9025947

Please sign in to comment.