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

Using weakdeps to reduce load time on Julia v1.9 #270

Closed
wants to merge 2 commits into from

Conversation

oschulz
Copy link
Contributor

@oschulz oschulz commented Apr 4, 2023

Before (StructArrays v0.6.15):

julia> @time_imports import StructArrays, StaticArraysCore, Tables
      0.5 ms  DataValueInterfaces
      4.2 ms  DataAPI
      0.5 ms  IteratorInterfaceExtensions
      0.4 ms  TableTraits
    127.2 ms  Tables
      4.1 ms  StaticArraysCore
      0.2 ms  Adapt
      1.9 ms  GPUArraysCore
     34.5 ms  StructArrays

This PR:

julia> @time_imports import StructArrays, StaticArraysCore, Tables
      1.1 ms  DataAPI
      0.4 ms  Adapt
      1.7 ms  GPUArraysCore
     27.5 ms  StructArrays
      3.0 ms  StaticArraysCore
      0.7 ms  StructArrays  StructArraysStaticArraysCoreExt
      0.2 ms  DataValueInterfaces
      0.2 ms  IteratorInterfaceExtensions
      0.1 ms  TableTraits
     31.4 ms  Tables
      0.4 ms  StructArrays  StructArraysTablesExt

@oschulz oschulz force-pushed the weakdeps branch 2 times, most recently from 9eeb22b to fc5d289 Compare April 4, 2023 07:41
@oschulz oschulz marked this pull request as draft April 4, 2023 21:11
@oschulz oschulz marked this pull request as ready for review April 4, 2023 21:48
@oschulz
Copy link
Contributor Author

oschulz commented Apr 4, 2023

Looks like the test failures on nightly are due to changed output formatting in doctests.

@oschulz
Copy link
Contributor Author

oschulz commented Apr 21, 2023

@piever , @aplavin what do you think?

@aplavin
Copy link
Member

aplavin commented Apr 21, 2023

I'm totally indifferent to this, because these packages are lightweight "*Core" interface packages anyway.
Given extensions, is there any need to use eg StaticArraysCore instead of StaticArrays itself?

And I'm not a member of this repo anyway :)

@oschulz
Copy link
Contributor Author

oschulz commented Apr 21, 2023

Given extensions, is there any need to use eg StaticArraysCore instead of StaticArrays itself?

I think for now it needs to be StaticArraysCore, because StructArrays will still depend on it with pre-v1.9 Julia.

@oschulz
Copy link
Contributor Author

oschulz commented Apr 21, 2023

@aplavin: And I'm not a member of this repo anyway :)

I just looked at recent contributions. :-) But I think I should have asked @jishnub and @piever instead?

@jishnub
Copy link
Member

jishnub commented Apr 21, 2023

I'm not a member either

@piever
Copy link
Collaborator

piever commented May 5, 2023

Makes sense, but maybe it'd be good for @N5N3 to look at this because of the overlap with #265. If I understand correctly, the issue is that depending on StaticArrays proper (rather than StaticArraysCore) allows for a more efficient implementation of broadcasting. In that case, maybe the simplest is to wait that 1.9 comes out and then use a weak dependency on StaticArrays?

Intuitively, I would think that the extra load time on older julia versions is a lesser issue that either worse performance or increased code complexity.

@oschulz
Copy link
Contributor Author

oschulz commented May 5, 2023

If I understand correctly, the issue is that depending on StaticArrays proper (rather than StaticArraysCore) allows for a more efficient

Oh, right, then we should go for StaticArrays proper as in #265 .

@oschulz
Copy link
Contributor Author

oschulz commented May 5, 2023

Shall I take StaticArrays out of this PR then, and only do Tables and GPUArraysCore in here?

@piever
Copy link
Collaborator

piever commented May 14, 2023

Let's wait just a little bit longer to see if @N5N3 has any opinion on this. But yes, maybe the simplest is to just do Tables and GPUArraysCore in here so that we avoid conflict with #265.

@N5N3
Copy link
Contributor

N5N3 commented May 14, 2023

LGTM. I think we can merge this without change. (#265 needs rebasing anyway as IIUC we have decided not to use Requires.jl)

@piever piever closed this May 18, 2023
@piever piever reopened this May 18, 2023
@piever
Copy link
Collaborator

piever commented May 18, 2023

Thanks for the input, then I imagine it can be merged as is (moving all functionality to extensions). Any ideas why CI is failing?

@N5N3
Copy link
Contributor

N5N3 commented May 18, 2023

IIRC, NamedTuple has been better printed on master. All failures are doctest error.

@piever
Copy link
Collaborator

piever commented May 18, 2023

I see, but what about the invalidation action? It seems as though it is struggling with Pkg operations.

@N5N3
Copy link
Contributor

N5N3 commented May 18, 2023

Looks like an upstream issue JuliaLang/Pkg.jl#3327

@oschulz
Copy link
Contributor Author

oschulz commented May 26, 2023

So can we merge this?

@oschulz
Copy link
Contributor Author

oschulz commented May 29, 2023

Bump @piever

@piever
Copy link
Collaborator

piever commented May 30, 2023

The PR itself LGTM. I'm a bit uncomfortable that using weak dependencies breaks the invalidation CI, but it doesn't look like there's a way around this. I'm planning to merge and tag in the next few days (there are a few PRs about to be merged that can probably go in the same release).

@oschulz
Copy link
Contributor Author

oschulz commented May 30, 2023

Thanks @piever !

@@ -38,3 +43,5 @@ for (f, g) in zip((:append!, :prepend!), (:push!, :pushfirst!))
end
Copy link
Member

@aplavin aplavin Jun 17, 2023

Choose a reason for hiding this comment

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

When put into extension, these functions are kinda-piracy: loading Tables changes a completely independent method, eg Base.push!(::StructVector, ::Any).

Copy link
Member

@aplavin aplavin Jun 17, 2023

Choose a reason for hiding this comment

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

Maybe they aren't needed at all? Not sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, that's a very good point, we really shouldn't do that. That code may be necessary - we may have to keep Tables as a hard dependency. But maybe Tables itself could be made more lightweight using Pkg extensions or so?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah, that's a very good point, I hadn't thought about that. Yes, we do need Tables for basic functionality like pushing or appending to a StructVector effectively, so that should definitely stay a hard dependency. Still, it is supposed to be an interface package, so that should be OK.

@aplavin
Copy link
Member

aplavin commented Jul 13, 2023

Can this get merged without Tables part, keeping Tables intergration as is?

@oschulz
Copy link
Contributor Author

oschulz commented Jul 13, 2023

Can this get merged without Tables part, keeping Tables intergration as is?

I think so - should I just take the Tables part out?

@piever
Copy link
Collaborator

piever commented Aug 24, 2023

Sorry for the slow reply! Yes, this but without the Tables.jl part can be merged.

@oschulz
Copy link
Contributor Author

oschulz commented Oct 26, 2023

Sorry, I lost track of this PR, I'll take Tables out.

@piever
Copy link
Collaborator

piever commented Nov 1, 2023

Sorry, I lost track of this PR, I'll take Tables out.

No worries! In the end, the relevant part of this PR has been incorporated in #265 so they'll end up merged together, I imagine this one here can be closed.

@piever piever closed this Nov 1, 2023
@oschulz
Copy link
Contributor Author

oschulz commented Nov 2, 2023

Good point. let's just move on with #265, less merge conflicts then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants