Code Monkey home page Code Monkey logo

Comments (8)

ndmitchell avatar ndmitchell commented on May 21, 2024 2

I've switched, and it goes 3x faster.

from weeder.

ndmitchell avatar ndmitchell commented on May 21, 2024

Foundation string already gives a win, although since foundation is broken on Windows ghci I don't want to switch yet. Tickets in foundation at haskell-foundation/foundation#326 and haskell-foundation/foundation#332.

from weeder.

vincenthz avatar vincenthz commented on May 21, 2024

Is the next bottleneck in foundation ? And if so, do you have a list of heavy functions ?

from weeder.

ndmitchell avatar ndmitchell commented on May 21, 2024

It's hard to say where the bottleneck is. Profiling tells me it's validating UTF8 bytes. Removing that code and doing an unsafe convert has zero impact on the time.

from weeder.

ndmitchell avatar ndmitchell commented on May 21, 2024

I just added a directory str which has various String implementations, and a script go.bat which compiles each in turn and runs a benchmark. For my benchmark, I checked out Shake, did a stack init && weeder --build. I then ran str\go.bat C:\Neil\shake and it gave:

Warnings match
Str-ByteString
Execution time: 1.850 s
Execution time: 1.834 s
Execution time: 1.855 s
Execution time: 1.854 s
Execution time: 1.857 s
Str-Foundation-Unsafe
Execution time: 2.249 s
Execution time: 2.224 s
Execution time: 2.240 s
Execution time: 2.223 s
Execution time: 2.249 s
Str-Foundation
Execution time: 2.231 s
Execution time: 2.232 s
Execution time: 2.243 s
Execution time: 2.232 s
Execution time: 2.239 s
Str-String
Execution time: 4.475 s
Execution time: 4.481 s
Execution time: 4.479 s
Execution time: 4.468 s
Execution time: 4.417 s
Str-Text
Execution time: 2.074 s
Execution time: 2.060 s
Execution time: 2.079 s
Execution time: 2.061 s
Execution time: 2.081 s

Given this is a laptop, I'd just go for the minimum when comparing, which means String < Foundation < Text < ByteString - so Foundation is the worst non [Char] performer. Profiling suggests its UTF8 validation, but Foundation-Unsafe (which just does the conversion without checking) is only fractionally faster. This is using foundation from git HEAD as of 2 minutes ago.

There are a couple of places I've had to write the functions:

I don't really know where the actual bottleneck is.

from weeder.

vincenthz avatar vincenthz commented on May 21, 2024

on HEAD you don't need removeR anymore, and I think my latest benchmarks seem to indicate it's better than it was. The windows benchs seems much slower than the linux bench, I'm not sure how to explain this; seems some kind of general haskell slowdown, not foundation related though.

Related to the validation, I think it's just inflated by the insertion of all the SCC when doing profiling, it doesn't seems to be that costly when used without profiling, which make the profile a bit useless to find out what is actually costing the most.

from weeder.

ndmitchell avatar ndmitchell commented on May 21, 2024

Latest timings:

Str-ByteString
Execution time: 1.022 s
Execution time: 1.012 s
Execution time: 1.010 s
Execution time: 1.010 s
Execution time: 1.010 s
Str-Foundation-Unsafe
Execution time: 1.161 s
Execution time: 1.154 s
Execution time: 1.165 s
Execution time: 1.172 s
Execution time: 1.166 s
Str-Foundation
Execution time: 1.175 s
Execution time: 1.183 s
Execution time: 1.181 s
Execution time: 1.182 s
Execution time: 1.181 s
Str-String
Execution time: 2.403 s
Execution time: 2.399 s
Execution time: 2.391 s
Execution time: 2.412 s
Execution time: 2.467 s
Str-Text
Execution time: 1.088 s
Execution time: 1.085 s
Execution time: 1.081 s
Execution time: 1.082 s
Execution time: 1.080 s

So still worse than Text. As you say, profiling isn't really helping much anymore, so I don't know what to suggest. The Str module is a fair bit simpler now though, see 16a3440.

I guess one option would be to use the very cheap foundation/bytestring conversion, and switch individual functions out for bytestring, which would say which foundation function was the expensive one.

from weeder.

ndmitchell avatar ndmitchell commented on May 21, 2024

It's now way faster than it was. Considering this one "solved".

from weeder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.