Skip to content

Conversation

@JackStouffer
Copy link
Contributor

@JackStouffer JackStouffer commented Jul 28, 2016

Benchmark code here: https://gist.github.com/JackStouffer/af53d497532a864f56a5b53cb35cd438

Gives about a 40% speed increase:

# old
$ ldc2 -O5 -release -boundscheck=off test.d && ./test
Total time: 5 secs, 266 ms, 64 μs, and 3 hnsecs

# new
$ ldc2 -O5 -release -boundscheck=off test.d && ./test
Total time: 3 secs, 295 ms, 663 μs, and 7 hnsecs

@JackStouffer
Copy link
Contributor Author

Ping @9il

@codecov-io
Copy link

codecov-io commented Jul 28, 2016

Current coverage is 88.74% (diff: 100%)

Merging #4674 into master will decrease coverage by <.01%

@@             master      #4674   diff @@
==========================================
  Files           121        121          
  Lines         74037      74043     +6   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          65705      65709     +4   
- Misses         8332       8334     +2   
  Partials          0          0          

Powered by Codecov. Last update 4a634ed...da24815

@9il
Copy link
Member

9il commented Jul 28, 2016

LGTM

@9il
Copy link
Member

9il commented Jul 28, 2016

Please add small msg to change log

@JackStouffer
Copy link
Contributor Author

@9il Done

@9il
Copy link
Member

9il commented Jul 28, 2016

@JackStouffer please add test (to the PR description) with global __gshared char[] integer number and pragma(inline, false) for parse functions. 4x-5x is large number, so, we need to be sure that LDC optimisation does not break the test.

@wilzbach
Copy link
Contributor

@JackStouffer please add test with global __gshared char[] integer number and pragma(inline, false) for parse functions. 4x-5x is large number, so, we need to be sure that LDC optimisation does not brake the test.

IIRC @klickverbot pointed out that a good way to prevent LDC optimizations is to use separate files & annotate the tested methods with extern.

I have a small repo for benchmark scripts which are separately compiled and then linked, maybe that helps you?

@9il
Copy link
Member

9il commented Jul 28, 2016

btw, pragma(inline, false) works correctly only in the recent LDC alpha, or master

@JackStouffer
Copy link
Contributor Author

Rebased.

Will add extra test when I get time.

@JackStouffer
Copy link
Contributor Author

@9il I updated the benchmark code here to your requests: #4597

@JackStouffer
Copy link
Contributor Author

Ping @9il

@andralex
Copy link
Member

This doesn't look right. Most code should stay the same. The only change is at the top level, where decodable strings should be replaced with byChar or .representation.

@andralex
Copy link
Member

Where is part 1? I hope it doesn't make similar changes... :)

@JackStouffer
Copy link
Contributor Author

@andralex Here's the problem, as outlined here

The reason why this is so messy is parse takes its range by ref, so byCodeUnit cannot be used without using refRange, which requires using &r, which is unsafe. So the only solution left is to do it manually with a bunch of static ifs.

I tried putting the refRange.byCodeUnit in a @trusted block, but that resulted in a speed pessimization (I'm guessing due to the inability to inline at that point).

@andralex
Copy link
Member

@JackStouffer then just work on a temporary and in the end assign the reference from it. It's a classic.

@JackStouffer
Copy link
Contributor Author

I don't understand. Operate on a temporary and reassign it how?

If I make a copy of p inside of parse and then use byCodeUnit on that, the copy of p is copied again by byCodeUnit and that is advanced and not the copy of p. So I would still have to manually popFront the copy in order to reassign it to p.

@JackStouffer
Copy link
Contributor Author

Ping @andralex @9il

suitable `outer` pointer))
$(LI Conversions from strings to number types using $(REF to, std,conv)
and $(REF parse, std,conv) were optimized. On average, integer types
are three times faster, and floating point types are 40% faster.)
Copy link
Member

Choose a reason for hiding this comment

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

change log should be updated. ping @wilzbach . You wanted to change current change log system

@9il
Copy link
Member

9il commented Oct 6, 2016

@JackStouffer it is save to reassing ubyte array to a string after integer parsing. Please implement Andrei's suggestions

@JackStouffer
Copy link
Contributor Author

I will get back to this eventually. I'm a bit swamped with school and work right now, so maybe around Thanksgiving.

@andralex
Copy link
Member

@JackStouffer thanks, ping me when ready.

@JackStouffer
Copy link
Contributor Author

Closed in favor of #5015

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.

5 participants