xero-ruby icon indicating copy to clipboard operation
xero-ruby copied to clipboard

Improve require time by using `useAutoload: true`

Open technicalpickles opened this issue 3 years ago • 1 comments

Requiring xero-ruby can take quite awhile because of the number of classes and modules. This time adds up especially for apps that use multiple OpenAPI generated libraries. https://github.com/OpenAPITools/openapi-generator/issues/12648 describes it well.

There is a fairly recently feature to switch requires to using autoload which don't actually load until a constant is used: https://github.com/OpenAPITools/openapi-generator/pull/13153

I'm not familiar enough with OpenAPI to know where to configure this though or I'd put together a PR>

technicalpickles avatar Sep 02 '22 15:09 technicalpickles

It would be great to get some progress on this. This gem is the slowest to load of all the ones we use.

@technicalpickles I'm not sure if I'm reading it correctly, but at the time of writing it looks like the version of the OpenAPI Generator being used hasn't been updated for 5 years and is still 4.3.0.

https://github.com/XeroAPI/xero-ruby/blob/ab062501495906aa62c43c7a860a48ba16d8194d/.openapi-generator/VERSION#L1

The useAutoload option was added in version 6.1, so Xero would need to upgrade their version of OpenAPI Generator first. That is probably a bit more involved than just enabling an option, but I'd expect there are some other benefits to upgrading outside of this feature.

@sangeet-joy-tw It looks like you are the most active maintainer of this repository. Any chance you could comment on this? It's a non-breaking option that will deliver a big performance increase, and if we're lucky it's a simple change!


Another place that could be looked to for improvements would be making it easier to selectively require the various parts of this gem, or even splitting it into multiple separate gems (eg: xero-core, xero-accounting-api). For example mI'd imagine the majority of users are only using a couple of the APIs, and relatively few applications are using the UK, NZ and AU payroll modules.

robotfelix avatar Jul 03 '25 15:07 robotfelix