Skip to content

Conversation

@JackStouffer
Copy link
Contributor

@9il
Copy link
Member

9il commented Jul 22, 2016

please benchmarks with combination with previous one PR

@JackStouffer
Copy link
Contributor Author

Just tested it, still slower and with no noticeable difference in speed.

Hmm, I'm looking at the profile output and I don't see what could be causing the 8x slower speeds.

@9il
Copy link
Member

9il commented Jul 22, 2016

maybe inlining bug?

@JackStouffer
Copy link
Contributor Author

JackStouffer commented Jul 22, 2016

I don't think so, but I am a novice at assembly. I found LDC's output of the function, but I don't see a call for it anywhere, so I guess it was inlined at every call point

@dnadlinger
Copy link
Contributor

You can also try the LLVM IR output (-output-ll), which you might find easier to read as it is higher-level and (partially) has descriptive names.

std/utf.d Outdated
buf, decodeFront!(UseReplacementDchar.yes)(r));
auto c = r.front;

if (c.isASCII)
Copy link
Member

Choose a reason for hiding this comment

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

Possibly isASCII is not inlined, just use plain old < 0x80

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No effect

@JackStouffer
Copy link
Contributor Author

Ok, I think I've figured it out. byUTF spends time decoding dchars when toUTF8 correctly skips that step with dstrings.

Will post numbers soon.

@JackStouffer
Copy link
Contributor Author

JackStouffer commented Jul 23, 2016

Well, that did make the UTF string faster, but I forgot that the ascii string isn't using that code path, so no change :/

$ ./test

ASCII w/ old    153 ms, 351 μs, and 1 hnsec
ASCII w/ new    533 ms, 803 μs, and 3 hnsecs
UTF w/ old  1 sec, 333 ms, 845 μs, and 4 hnsecs
UTF w/ old  690 ms, 884 μs, and 6 hnsecs

@JackStouffer JackStouffer changed the title Added ASCII fast path in std.utf.byUTF Added fast paths in std.utf.byUTF Jul 23, 2016
@JackStouffer
Copy link
Contributor Author

Regardless of the other PR, these are two good optimizations that IMO should be pulled.

@JackStouffer JackStouffer force-pushed the utf2 branch 2 times, most recently from 095939f to 47f0c1d Compare July 26, 2016 15:24
@JackStouffer
Copy link
Contributor Author

Fixed test errors

@codecov-io
Copy link

Current coverage is 88.68% (diff: 100%)

Merging #4642 into master will increase coverage by <.01%

@@             master      #4642   diff @@
==========================================
  Files           121        121          
  Lines         73827      73833     +6   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          65471      65477     +6   
  Misses         8356       8356          
  Partials          0          0          

Powered by Codecov. Last update 6db08d3...46594d6

@JackStouffer
Copy link
Contributor Author

Ping

@JackStouffer
Copy link
Contributor Author

Ping @9il

@wilzbach
Copy link
Contributor

wilzbach commented Aug 26, 2016

please benchmarks with combination with previous one PR

How about starting to include such benchmarks in a special benchmark folder?
This would make it easier for future improvements & also help to prevent regressions.

I believe @burner is envisioning sth. similar with #2995, but we could still start to collect the benchmark script as (a) it comes "for free" (they are already written) and (b) might help to move forward with a future "full-blown" benchmark suite as we then already have real scripts and know what functions / features are lacking.

Btw runtime has already gone a similar way.

(pinging @qznc as he has written a nice blog post about benchmarking Phobos)

@JackStouffer
Copy link
Contributor Author

Ping @9il @klickverbot

I think these two optimizations are good to go regardless of the other PR.

@andralex andralex merged commit 2955c8c into dlang:master Sep 17, 2016
@JackStouffer
Copy link
Contributor Author

@andralex Thanks!

@JackStouffer JackStouffer deleted the utf2 branch September 17, 2016 00:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants