Skip to content

Conversation

@bbakerman
Copy link
Member

@bbakerman bbakerman commented Jul 15, 2021

This is a WORK implementation of building a GraQhlSchema object with only less traversal

At this stage I left the OLD code in there so you could see what's different

It would be cleaned up if we accepted this code.

I copied the bench mark from the previous PR and run it.

It shows that this code as is BETTER - but not ground breakingly better.

Start

Benchmark                                    Mode  Cnt   Score   Error  Units
SchemaBenchMark.benchMarkLargeSchemaCreate  thrpt   15  18.134 ± 1.099  ops/s

This work as is

Benchmark                                    Mode  Cnt   Score   Error  Units
SchemaBenchMark.benchMarkLargeSchemaCreate  thrpt   15  19.771 ± 0.685  ops/s

I then took out the validation steps just to see what would happen to the numbers.

Benchmark                                    Mode  Cnt   Score   Error  Units
SchemaBenchMark.benchMarkLargeSchemaCreate  thrpt   15  25.906 ± 0.370  ops/s

I then took out the type replacement step and validation just to see. This is not valid of course

Benchmark                                    Mode  Cnt   Score   Error  Units
SchemaBenchMark.benchMarkLargeSchemaCreate  thrpt   15  30.256 ± 1.171  ops/s

Having the ability to skip validation would help. Type replacements MUST happen.

If we could find a way to combine type replacement with the previous steps then it would be better. But that might
be impossible - we need ALL the types collected to do type ref replacements... OR do we. ??? Anyway that's for another PR based on this one

@bbakerman bbakerman added this to the 17.0 milestone Jul 15, 2021
import static graphql.util.TraversalControl.CONTINUE;

/**
* This ensure that all fields have data fetchers and that unions and interfaces have type resolvers
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this to a schem.impl package just to clean things up. Its kinda of a private thing and not general purpose

@@ -1,12 +1,26 @@
package graphql.schema;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again I moved this to a schem.impl package just to clean things up. Its kinda of a private thing and not general purpose


import java.util.List;

public class MultiReadOnlyGraphQLTypeVisitor implements GraphQLTypeVisitor {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allows us to call N visitors at once - read only ones that can change nodes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that public api?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not so sure about the semantics here: they don't compose completely, right? I can't return a ABORT/Quit anymore, for example.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They dont compose generically - they run one after the other. I have made it @Internal and improved the javadoc on what it does

@@ -1,11 +1,24 @@
package graphql.schema;
package graphql.schema.impl;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again again I moved this to a schem.impl package just to clean things up. Its kinda of a private thing and not general purpose

@@ -1,7 +1,9 @@
package graphql.schema;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again again again I moved this to a schem.impl package just to clean things up. Its kinda of a private thing and not general purpose

@bbakerman bbakerman added the performance work that is primarily targeted as performance improvements label Jul 15, 2021
…uring_schema_build

# Conflicts:
#	src/test/java/benchmark/SchemaBenchMark.java
@andimarek andimarek self-requested a review July 18, 2021 04:40

final GraphQLSchema finalSchema = new GraphQLSchema(partiallyBuiltSchema, codeRegistry, allTypes, interfaceNameToObjectTypes);
schemaUtil.replaceTypeReferences(finalSchema);
if (true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't look right

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah as discussed direct - this was to show the new code versus the old.

The PR now has this removed and cleaned up

*/
@Internal
public GraphQLSchema(GraphQLSchema partiallyBuiltSchema,
GraphQLCodeRegistry codeRegistry, ImmutableMap<String, GraphQLNamedType> typeMap,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be one line per arg, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


import java.util.List;

public class MultiReadOnlyGraphQLTypeVisitor implements GraphQLTypeVisitor {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that public api?


import java.util.List;

public class MultiReadOnlyGraphQLTypeVisitor implements GraphQLTypeVisitor {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not so sure about the semantics here: they don't compose completely, right? I can't return a ABORT/Quit anymore, for example.

…uring_schema_build

# Conflicts:
#	src/main/java/graphql/schema/SchemaTransformer.java
}

public static void replaceTypeReferences(GraphQLSchema schema) {
final Map<String, GraphQLNamedType> typeMap = schema.getTypeMap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this code: it looks suspicious that we grab all types to iterate. I think we can do better and maybe this is not even completely correct. But we can leave it for another PR.

@bbakerman bbakerman merged commit 128e3d5 into master Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance work that is primarily targeted as performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants