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

move NetLogo to new Vector implementation in 2.13.2? #1823

Open
SethTisue opened this issue Mar 10, 2020 · 12 comments
Open

move NetLogo to new Vector implementation in 2.13.2? #1823

SethTisue opened this issue Mar 10, 2020 · 12 comments

Comments

@SethTisue
Copy link
Collaborator

scala/scala#8534 will likely land soon and be included in Scala 2.13.2

NetLogo's LogoList is just a wrapper around scala.collection.immutable.Vector[AnyRef], so the performance differences should carry over directly to NetLogo

some of the improvements give huge speedups on very long lists. but perhaps in NetLogo such huge lists aren't that common

but also, another change in the new Vector is that small sizes are special-cased. I would expect even ordinary NetLogo models to benefit from that — if they use lists at all, I mean. they can expect to benefit in speed, but at least as important, they will use benefit in lower memory usage. users running with large number of agents, where each agent uses small lists, could see a noticeable drop in RAM usage

and it would be interesting to run the NetLogo benchmark suite before-and-after this change

but.... huge caveat.... you'd have to move to Scala 2.13 first. curious, is any work on that planned or in progress?

@SethTisue
Copy link
Collaborator Author

SethTisue commented Apr 23, 2020

Scala 2.13.2 is now available and includes the new Vector https://github.com/scala/scala/releases/tag/v2.13.2

@SethTisue
Copy link
Collaborator Author

Scala 2.13.3 is out, so the new Vector is now pretty well battle-tested

@EwoutH
Copy link
Contributor

EwoutH commented Nov 17, 2022

@SethTisue Did you already try running scala-collection-compat over the repository? If so, what where the results?

@SethTisue
Copy link
Collaborator Author

SethTisue commented Nov 17, 2022

@EwoutH I think you might be misunderstanding the purpose of scala-collection-compat. it's useful for using certain 2.13 features from 2.12, but we aren't staying on 2.12 and we don't need those features. I don't think scala-collection-compat is a useful tool for upgrading to 2.13, which is what I'm suggesting here

@brandesNW
Copy link
Contributor

brandesNW commented Nov 17, 2022 via email

@EwoutH
Copy link
Contributor

EwoutH commented Nov 17, 2022

it's useful for using certain 2.13 features from 2.12, but we aren't staying on 2.12 and we don't need those features.

In that case I think I indeed misunderstood, I thought Collection213Upgrade could help upgrade to 2.13 without keeping 2.12 compatiblity.

Collection213Upgrade

The Collection213Upgrade rewrite upgrades to the 2.13 collections without the ability to compile the code-base with 2.12 or 2.11. This rewrite is suitable for applications that don't need to cross-compile against multiple Scala versions.

@SethTisue
Copy link
Collaborator Author

SethTisue commented Nov 17, 2022

@EwoutH Oh, sorry! The rewrite rules, I forgot about those. Yes, you're absolutely right, that could be helpful here. (I thought you meant the scala-collection-compat library.)

@SethTisue
Copy link
Collaborator Author

SethTisue commented Nov 17, 2022

What version of scala do you think we should aim for (if we have the resources) for the next release (or the one after).

You should go straight to 2.13.10. There's no reason to use any intermediate version as a way station.

You can worry about Scala 3 later. It's best to get on 2.13 first.

What steps need to be taken to upgrade to scala 2.13.2 ?

Bump the version number, see what breaks, and fix it :-)

You'll want to read https://github.com/scala/scala/releases/v2.13.0 very carefully and absorb it thoroughly.

Anything in the notes in is a potential concern, but by far the biggest area of change is the Scala collections library.

As the notes say, "Most ordinary code that used the old collections will continue to work as-is", but in any large codebase like NetLogo's, "most" will leave you with some work to do.

After bumping scalaVersion, you could start by getting Test/update to work — bumping dependency versions if needed (hopefully the recent upgrades have already taken care of most or all of them), and finding alternatives for any dependencies that don't exist for 2.13 (if any — knock on wood!).

Then get the code to compile on 2.13. as suggested by @EwoutH, Collection213Upgrade could be helpful here.

Then get the tests to pass.

Then do all of the extensions, too.

@SethTisue
Copy link
Collaborator Author

I don't know how many warnings the NetLogo codebase generates or whether y'all are in the habit of ignoring them? During the upgrade, there will probably be new warnings that will alert you of potential issues and you won't want to tune them out.

@SethTisue
Copy link
Collaborator Author

Oh, and I forgot to mention:

Upgrading from 2.12? Enable -Xmigration while upgrading to request migration advice from the compiler

(This is in the 2.13.0 release notes, but it's easy to miss.)

@brandesNW
Copy link
Contributor

brandesNW commented Nov 17, 2022 via email

@EwoutH
Copy link
Contributor

EwoutH commented Dec 21, 2022

I did try to apply the Collection213Upgrade rewrite rule using Scala Steward. This rule was recently added to Scala Steward.

Unfortunately it failed, here is the log.

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

No branches or pull requests

3 participants