Commit Graph

1395 Commits

Author SHA1 Message Date
Charles Blake
42f8f1cd1f Fix unnecessarily slow set building from openArray.
The estimation of the initialSize as simply array len + 10 was too small for
for all but the smallest sets.  It would not elide/skip one final enlarge().
That last one is actually always the most expensive enlarge().  Indeed, in a
series where one to start from tiny and build up the table..that last one is
about 50% of all the enlarging time in general.  So, this simple and reasonable
optimization (compared to just starting at 64) was only helping about half as
much as it could.

Introduce a rightSize() proc to be the inverse to mustRehash().  Export it
to clients since pre-sizing is externally useful in set construction and the
current mustRehash rules are opaque and beyond the control of clients.

Also add test module logic to check that rightSize() and mustRehash() are
inverses in the appropriate sense..not really in a block/assertion throwing
unit test since this is a peformance nice-to-have issue rather than about
basic correctness.  (Also, fix a too vs. two typo in doc comment.)
2015-02-07 09:37:17 -05:00
Charles Blake
8e685585a6 Merge /home/cb/pkg/nim/Nim into devel 2015-02-07 09:32:27 -05:00
Araq
0b5c42f405 configuration system supports %= to access environment variables 2015-02-07 12:55:23 +01:00
Araq
74c6c8c903 compiler distinguishes between 2 different 'var' types for C++ interop; code cleanups 2015-02-07 10:48:07 +01:00
Araq
e84834db79 lots of C++ codegen improvements 2015-02-07 10:48:07 +01:00
Fabio Cevasco
99b14c8d8d newRollingFileLogger - fmtStr is always set to defaultFmtStr 2015-02-06 22:40:21 +01:00
Charles Blake
65ce08f38c Add hcode. Re-factor rawGet. Fix infinite loop.
Replace state enum with a cached hash code which has the same memory overhead
and locality as the enum, but can really speed things up with non-integer-like
keys (keys for which either hash() or == take more than couple cycles, or where
the key data is "indirect" and might incur another cache miss).  To function as
both empty/filled state and a hash code cache, it only needs to be ensured that
hash codes are non-zero for any real key.  That is done at the one place in the
whole file hash() is called.  Keep convention clear via isFilled() & isEmpty().
An isDeleted state will no longer be necessary as per below excl/inf loop fix.

Since some use sites know hc and some do not, re-factor rawGet into two forms -
one with known hash code and one with an unknown HC that returns it. Both forms
still return <0 on missing, but returns the much more informative "-1 - index".
That return can be quickly inverted by -1 - result to recover the index where
insert should happen, provided no modifications are made to the table in the
meantime.  This protocol retains the prior <0 interface and also makes it easy
to avoid unnecessary duplicate search work in procs like containsOrInclImpl
(which formerly searched in the initial get and AGAIN in rawInsert).  Strip the
searching part out of rawInsert to "make it even more raw".  swap(s.data, n) a
bit earlier so rawGet and rawGetKnownHC can have similar parameter lists and
integrate well with rawInsert/code sharing between Set and OrderedSet impls.

This PR also fixes infinite looping upon too many deletes. [ The deleted state
(aka "tombstone") approach is vulnerable to the table filling up with deleted
items which forces giant scans for missing keys which could be anywhere.  In
the version prior to this PR, table wraparound wasn't even detected yielding
infinite loops. ] This PR changes excl() from marking slots as deleted to Knuth
algo 6.4R, "local/incremental moveback rehashing" - adapted from Knuth's h->h-1
to the cache-friendlier h->h+1 probe sequence and adapted from "gotos" to a new
doWhile template.  This method restores the table to a state that would have
resulted from pure inserts (in some order).  Update nextTry accordingly.  Since
linear probing can degrade a little faster, 50% rather than 66% may be a better
default growth threshold, but users should be able to adjust threshold anyway.

Old unit tests all pass.  More extensive testing in this module is probably
warranted before taking similar enhancements over to collections.tables.
2015-02-06 09:24:20 -05:00
def
416456cefe Try to fix unittest for JS backend, still not working 2015-02-04 21:44:25 +01:00
Andreas Rumpf
08ee62a783 Merge pull request #2049 from def-/permutations
Add nextPermutation and prevPermutation
2015-02-04 17:12:35 +01:00
Andreas Rumpf
f0cdb49c3b Merge pull request #2027 from dumndummer/patch-1
Update sequtils.nim
2015-02-04 10:38:50 +01:00
dumndummer
07f42fa612 Changed name 'pred' to 'op' in mapIt template 2015-02-02 14:42:00 +00:00
def
1ae4d535cd Add nextPermutation and prevPermutation
Fits best into algorithm module I guess. These are the most general
ways, an iterator could easily be implemented from this. Same algorithm
as in Rust: http://web.mit.edu/rust-lang_v0.11/doc/src/collections/var/tmp/alexp/rust/rust-0.11.0/src/libcollections/slice.rs.html#644
2015-02-01 18:29:01 +01:00
def
11a5a4a9a6 Fix SinglyLinkedRing in lists module
- SinglyLinkedRing's prepend was broken
- needed a tail so that prepend can work properly
- now append works as well, so I added it too
- simple testcase added as well
2015-02-01 03:04:18 +01:00
Andreas Rumpf
3b45ac44e1 Merge pull request #2010 from modk/freebsd-parallel-build
Fix parallel build on FreeBSD
2015-02-01 01:41:26 +01:00
reactormonk
014be3a29c Merge pull request #2020 from def-/mitems
mitems and mpairs
2015-02-01 05:19:47 +05:00
Araq
8f587e2eab fixes #2041 2015-01-31 11:49:19 +01:00
Araq
fe30ec83e2 nimsuggest improvements 2015-01-30 03:04:45 +01:00
modk
458e3b2f07 FreeBSD-specific code 2015-01-29 12:51:22 +01:00
dumndummer
c19fb7b366 Update sequtils.nim
Renamed param name 'pred' to 'op' in mapIt template to better correspond with map proc in system module
2015-01-28 21:44:52 +00:00
Dominik Picheta
6143393adb Move lib/pure/nodejs to compiler/nodejs. Ref #2017. 2015-01-28 14:58:31 +00:00
Andreas Rumpf
190cc01f24 Merge pull request #2017 from reactormonk/nodejs-binary
Algorithm to find the nodejs binary
2015-01-28 15:14:39 +01:00
Araq
dbe71c715e documented new C++ support 2015-01-28 12:59:04 +01:00
def
fa1e209b63 Typo 2015-01-28 02:31:26 +01:00
def
46cf40c40d Add mitems and mpairs where it makes sense 2015-01-28 02:31:26 +01:00
modk
e37e997868 Set status to something else than 0 2015-01-27 22:39:24 +01:00
Simon Hafner
842c7f67ca added suggested fixes 2015-01-27 13:04:27 -06:00
dumndummer
16254f49a8 Update sets.nim
corrected misspelled word in doc comment
2015-01-27 13:35:50 +00:00
Araq
26b853923c nimsuggest: first version 2015-01-27 01:36:19 +01:00
Araq
b2d1889951 bugfix: don't overwrite the number value in case of a parsing error 2015-01-27 01:33:48 +01:00
modk
71ad822833 Merge with current devel 2015-01-26 09:55:20 +01:00
modk
601b262a8d Fixes parallel build on FreeBSD 2015-01-26 00:06:43 +01:00
Dominik Picheta
defaf5d400 Logging module is now thread-safe. 2015-01-25 17:02:37 +00:00
Dominik Picheta
67e489d4e5 Merge pull request #2009 from gmpreussner/devel
Added complex conjugate
2015-01-25 12:39:55 +00:00
gmpreussner
defbd10c19 Added complex conjugate 2015-01-24 22:57:19 -05:00
Dominik Picheta
88450e76fd Merge pull request #1998 from Varriount/fix-1962
Fixes #1962
2015-01-24 11:34:53 +00:00
Varriount
0e65df4bbf Added documentation for the new http request procedures. 2015-01-23 22:06:57 -05:00
Varriount
41d11e0def Fix #1906 2015-01-22 18:34:33 -05:00
Varriount
38b7fb94ef Fixes #1962 2015-01-22 16:45:18 -05:00
Elie Zedeck
1845e05a34 Handle EPOLLHUP to avoid chaos/runaways when using certain file descriptors.
A concrete example is pipe file descriptors: they generate EPOLLHUP instead of a EPOLLIN (then 0 bytes read). The loop will run wild if this event is not handled.
2015-01-21 18:15:38 +03:00
Varriount
eb929bd61c Merge pull request #1842 from def-/unicode-reversed
Add reversed proc to unicode module
2015-01-17 18:53:46 -05:00
Varriount
b828bae80d Merge pull request #1967 from def-/more-renames
More renames
2015-01-16 21:27:07 -05:00
Flaviu Tamas
d24fb3d0b9 Fix named argument handling
Instead of trying to use the whole parameter, it uses just the RHS, as expected
2015-01-16 19:01:33 -05:00
def
aae3c6c8b7 Get rid of deprecation warnings in pegs 2015-01-16 00:23:33 +01:00
def
ae7ca46a09 Optimize unicode.reversed
Runs about 18 times faster:
- combining characters with boolean logic instead of binary search
- No more temporary sequence
- Optimize for ASCII characters
2015-01-15 23:11:02 +01:00
def
2a7a5a69d0 GitHub link fixes: nim-code -> nim-lang 2015-01-15 03:26:59 +01:00
Araq
20774ad43c fixes the integer conversion regressions 2015-01-13 20:56:31 +01:00
def
f2c1b3be13 Fix body in httpclient
- Never append a newline to the body in a HTTP post.
- Pass the entire body to redirections, including multipart data
2015-01-13 18:48:49 +01:00
Araq
4754d2dcbd Merge branch 'devel' of https://github.com/Araq/Nim into devel 2015-01-13 13:56:15 +01:00
Araq
f7ef00aa3b make net.nim compile again (quick workaround for a regression) 2015-01-13 13:55:56 +01:00
def
519ec304e4 Fix: Only handle EPOLLERR as an error event
When an EPOLLRDHUP is received with epoll_ctl, there can still be data
to be read. So we shouldn't immediately close the socket and abort.
2015-01-13 00:45:17 +01:00