Commit Graph

5003 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
dc85c2498b nimsuggest knows how to deal with files not belonging to the project 2015-02-07 13:15:30 +01:00
Araq
0b5c42f405 configuration system supports %= to access environment variables 2015-02-07 12:55:23 +01:00
Araq
1314e91ef5 fixes c++ codegen regression 2015-02-07 10:48:09 +01:00
Araq
d933fde40d yet another C++ bugfix 2015-02-07 10:48:08 +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
Dominik Picheta
d020ad097c Merge pull request #2081 from h3rald/patch-3
newRollingFileLogger - fmtStr is always set to defaultFmtStr
2015-02-06 22:05:10 +00: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
Araq
53f4c7758b fixes #1601 2015-02-05 13:12:20 +01:00
Araq
b44ee119c8 list CC executions properly again for --parallelBuild:1 2015-02-05 12:23:27 +01:00
Araq
c795a469bc fixes #2011 2015-02-05 12:23:26 +01:00
Andreas Rumpf
d41d9f704d Merge pull request #2067 from def-/tests-stuff
Tests stuff
2015-02-04 23:45:45 +01:00
def
25cee6e05b Clean up tests/static
tstaticparammacro still fails
2015-02-04 22:18:06 +01:00
def
1c4153790b Clean up tests/osproc 2015-02-04 22:15:30 +01:00
def
f18368bd3b Clean up tests/modules 2015-02-04 22:09:42 +01:00
def
1c34f30bbb Clean up tests/manyloc
named_argument_bug still fails
2015-02-04 21:57:24 +01:00
def
416456cefe Try to fix unittest for JS backend, still not working 2015-02-04 21:44:25 +01:00
def
0b4557b2ce Clean up tests/iter 2015-02-04 21:40:33 +01:00
def
546acfaf4e Clean up tests/effects 2015-02-04 21:20:01 +01:00
def
8a7f405eea Clear up tests/clearmsg 2015-02-04 20:42:37 +01:00
def
c58573b34a Fix name of generated C file in tester
- Makes tests/ccgbugs/tmissingvolatile work again
2015-02-04 20:41:29 +01:00
def
be33e55518 Clean up tests/bind 2015-02-04 20:32:54 +01:00
def
4fbf47ca5e Clean up tests/assert
1 test still fails:

- tunittests uses utemplates, which seems broken. not sure what it's
  supposed to do
2015-02-04 20:30:09 +01:00
def
e0ae9f5248 Clean up tests/stdlib
2 tests still fail:
- tircbot would need a benign pragma because of the locks
- tgetfileinfo uses os.getFileInfo() on nil, which segfaults instead of
  throwing an exception as the tester expects
2015-02-04 20:24:01 +01:00
def
1b91b3a2a5 Disable rodfiles tests for now 2015-02-04 20:10:57 +01:00
def
19993d73ed Add test for #1460 2015-02-04 20:10:50 +01:00
def
c3989f64ef Add test for #1459 2015-02-04 20:08:26 +01:00
def
402ada8f1d Add test for #1877 2015-02-04 20:00:28 +01:00
def
69b794cd7d Add test for #1259 2015-02-04 19:53:50 +01:00
def
d91368c8d0 Add test for #1836 2015-02-04 19:47:58 +01:00
Andreas Rumpf
08ee62a783 Merge pull request #2049 from def-/permutations
Add nextPermutation and prevPermutation
2015-02-04 17:12:35 +01:00
Araq
b5f1957588 fixes #2057 2015-02-04 12:51:54 +01:00
Araq
61e5f0dc51 fixes #2061 2015-02-04 12:51:53 +01:00
Andreas Rumpf
7f14d0e782 Merge pull request #2031 from reactormonk/high-cstring
Fixes #2030
2015-02-04 10:39:49 +01:00
Andreas Rumpf
47c157e05e Merge pull request #2047 from reactormonk/tests-for-497
added tests from issue #497
2015-02-04 10:39:24 +01:00
Andreas Rumpf
f0cdb49c3b Merge pull request #2027 from dumndummer/patch-1
Update sequtils.nim
2015-02-04 10:38:50 +01:00
Araq
a0d3bd16e7 fixes stupid regression 2015-02-04 00:52:46 +01:00
Araq
e75e421912 C++ support: codegen generates C++'s references and avoids copies 2015-02-04 00:52:45 +01:00
Araq
a400e8f7f3 better error message for auto-deref 2015-02-04 00:52:44 +01:00
reactormonk
8e98007dce Merge pull request #2055 from dumndummer/patch-4
Update macros.nim
2015-02-02 23:40:52 +05:00
dumndummer
9a1be7a9f3 Update macros.nim
minor doc comment spelling correction
2015-02-02 17:57:31 +00:00
dumndummer
07f42fa612 Changed name 'pred' to 'op' in mapIt template 2015-02-02 14:42:00 +00:00
def
03db4d2930 Adapt the tester for permutations
Uses the bool return value now
2015-02-02 08:06:19 +01: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
Araq
903ca78289 fixes #1989 2015-02-01 11:58:41 +01:00
Araq
a6082b2a20 slightly better docs for re module 2015-02-01 11:58:40 +01:00
Simon Hafner
43ddb4806b added tests from issue #497 2015-02-01 04:37:34 -06:00