vapor / fluent-mysql-driver

🖋🐬 Swift ORM (queries, models, relations, etc) built on MySQL.
MIT License
77 stars 52 forks source link

FluentMySQLConfiguration's memberwise initializer takes a minute to typecheck #219

Closed vzsg closed 1 year ago

vzsg commented 1 year ago

Describe the bug

This initializer, when used with nil coalescing all around the place like in the template, is causing the Swift compiler to typecheck for about an extra minute on M1 (146 seconds in total with dependencies already resolved).

In particular, this line seems to cause the issue in the template:

Environment.get("DATABASE_PORT").flatMap(Int.init(_:)) ?? MySQLConfiguration.ianaPortNumber

But I'm opening the issue here, because the same expression is used in the template project for Postgres, and that configuration builds "immediately" (71 seconds in total with dependencies already resolved).

To Reproduce

Steps to reproduce the behavior:

  1. git clone https://github.com/vapor/template-fluent-mysql
  2. cd template-fluent-mysql
  3. swift build
  4. Observe that the compilation hangs at the last batch of files in the App module.

Expected behavior

The template project should build as fast as it does with the Postgres driver.

Environment

Dependencies:

├── vapor<https://github.com/vapor/vapor.git@4.78.2>
└── fluent-mysql-driver<https://github.com/vapor/fluent-mysql-driver.git@4.4.0>
     └── mysql-kit<https://github.com/vapor/mysql-kit.git@4.7.1>
            └── mysql-nio<https://github.com/vapor/mysql-nio.git@1.7.0>

System:

gwynne commented 1 year ago

Wow. With Postgres I solved that by adding an explicit type... Had no idea MySQL was similarly affected. I'll see what I can do.