-
Notifications
You must be signed in to change notification settings - Fork 9
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
replace regex with indexOf #8
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Obligatory question: Did you test it? I.e. run the unit tests?
As mentioned earlier, the library does a lot of copying of lists, maps and sets where oftentimes it doesn't really have to, it was just simpler to write the code that way. E.g. keys.filter { it.startsWith("$key:") }
creates a new set.
Now, I have recently read that copying data is one of those things modern CPUs are really good at, so oftentimes it doesn't really matter. However, maybe Java is different (because all collections are on the heap, not on the stack).
So, to traverse all elements on a collection lazily, you can use Sequence
s. Sequences are pretty much the same thing as Java Stream
s.
If using these at some places actually has an impact, I'd be curious to know. Might as well have a negative impact due to the added indirection, don't know 🤷 .
library/src/commonMain/kotlin/de/westnordost/osm_legal_default_speeds/LegalDefaultSpeeds.kt
Outdated
Show resolved
Hide resolved
library/src/commonMain/kotlin/de/westnordost/osm_legal_default_speeds/LegalDefaultSpeeds.kt
Outdated
Show resolved
Hide resolved
library/src/commonMain/kotlin/de/westnordost/osm_legal_default_speeds/LegalDefaultSpeeds.kt
Outdated
Show resolved
Hide resolved
Yes :)
Yeah, normally it is no problem and often the JVM can handle smaller frequently created garbage. But the GraphHopper import is delicate and it might not be the same (as a method is called millions of times). Will profile it again after this change. But the build makes me headaches as sometimes it worked to push it to the local maven repo and sometimes not. |
Hm. Maybe the multiplatform setup is delicate... Is there an update for the multiplatform maven plugin? |
Also, I am not sure if publishing to local maven works if a local version with the same version number already exists. Maybe you need to delete the one you already published just then. |
…_speeds/LegalDefaultSpeeds.kt Co-authored-by: Tobias Zwick <[email protected]>
…_speeds/LegalDefaultSpeeds.kt Co-authored-by: Tobias Zwick <[email protected]>
…_speeds/LegalDefaultSpeeds.kt Co-authored-by: Tobias Zwick <[email protected]>
So from my point of view, this could be merged now. Or do you want to also try out |
Sure, feel free to merge it :) (I can't :) ) If you like or want it might be beneficial to setup the benchmark mentioned in #7 before merging, but this is up to you.
No, I think it is fine for me to approach this in smaller steps.
Maybe you activate github actions to run the tests automatically? |
It would be prudent to do so... but I am too lazy to do this now. I'd have to read up a bit about github actions first. A PR that enables that however would be welcome :-) |
btw: feel free to copy stuff from us https://github.com/graphhopper/graphhopper/blob/master/.github/workflows/build.yml (the node cache is probably not necessary) |
For #7. Not sure how to do performance tests in kotlin. Is there a native alternative for JMH?
Update: although this improves the import for my smaller test PBF it does not seem to improve the memory problems for planet.
Update: was a build problem