Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register type definitions lazily #11938

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

4e6
Copy link
Contributor

@4e6 4e6 commented Dec 24, 2024

Pull Request Description

close #10923

Changelog:

  • update: registerTypeDefinitions registers constructors lazily

Important Notes

The improvement of time spent in the registerTypeDefinitions method (highlighted):

before

2024-12-23-192336_1193x245_scrot

after

2024-12-23-192401_1197x253_scrot

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    TypeScript,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • Unit tests have been written where possible.

@4e6 4e6 added the CI: No changelog needed Do not require a changelog entry for this PR. label Dec 24, 2024
@4e6 4e6 self-assigned this Dec 24, 2024
Copy link
Member

@JaroslavTulach JaroslavTulach left a comment

Choose a reason for hiding this comment

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

  • Few style-like comments inline. Treat as opinions.
  • Overall this seems like the right change.
  • what's the impact on benchmarks?
  • explicitly: what's the impact on test/Benchmarks/src/Startup/*.enso startups?

* @param annotations the list of attached annotations
* @param args the list of argument definitions
*/
public record InitializationParts(
Copy link
Member

Choose a reason for hiding this comment

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

Does this new record have to be public? Because the record defines not just public constructor, but also public getters. I do not think we want people around the code base to call the getters.

Could we rather follow this example by @Akirathan where Pavel introduced FunctionSchema.Builder?

* @return the supplier providing the value with the mapping function applied
* @param <R> the result type
*/
public <R> CachingSupplier<R> map(Function<T, R> f) {
Copy link
Member

Choose a reason for hiding this comment

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

The "tendency towards functional style" is clear...

Copy link
Collaborator

Choose a reason for hiding this comment

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

I, on the other hand, really like it :)

this.constructorFunction =
buildConstructorFunction(
language, section, localScope, scopeBuilder, assignments, varReads, annotations, args);
initializationResultSupplier.map(
Copy link
Member

Choose a reason for hiding this comment

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

Interesting use of the new map function. The alternative would be to have a single field Supplier<InitializationResult> stored in the AtomConstructor. I seem to like it a bit more - shows the "fixed" vs. the lazily computed part of the structure.

new RuntimeAnnotation(annotation.name, closureRootNode)
}

new InitializationParts(
Copy link
Member

Choose a reason for hiding this comment

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

With the builder style, this would become:

AtomConstructor.newBuilder().
  section(...).
  scope(...).
  assignments(...).
  reads(...).
  args(defs);

Copy link
Member

@Akirathan Akirathan left a comment

Choose a reason for hiding this comment

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

LGTM. Agree with @JaroslavTulach on the commenteds about style. You don't have to schedule the benchmarks and compare them on this PR, but remember to please at least add a comment on this PR about the results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove 519ms startup overhead caused by registerTypeDefinitions
4 participants