summaryrefslogtreecommitdiff
path: root/libraries/base
Commit message (Collapse)AuthorAgeFilesLines
* base: Always clamp reads/writes to 2GB in lengthBen Gamari2020-01-241-9/+6
| | | | | | | | | | | | Previously we did this only on Darwin due to #17414. However, even on other platforms >2GB writes are on shaky ground. POSIX explicitly says that the result is implementation-specified and Linux will write at most 0x7ffff000, even on 64-bit platforms. Moreover, getting the sign of the syscall result correct is tricky, as demonstrated by the fact that T17414 currently fails on FreeBSD. For simplicity we now just uniformly clamp to 0x7ffff000 on all platforms.
* Fix more typos, via an improved Levenshtein-style correctorBrian Wignall2020-01-123-4/+4
|
* Module hierarchy: Iface (cf #13009)Sylvain Henry2020-01-061-1/+1
|
* Fix typos, via a Levenshtein-style correctorBrian Wignall2020-01-0415-16/+16
|
* testsuite: Skip T17499 when built against integer-simpleBen Gamari2019-12-271-1/+3
| | | | Since it routinely times out in CI.
* fixup! Fix endian handling w.r.t. CPP macro WORDS_BIGENDIANStefan Schulze Frielinghaus2019-12-242-2/+2
|
* Fix endian handling w.r.t. CPP macro WORDS_BIGENDIANStefan Schulze Frielinghaus2019-12-242-0/+6
| | | | | | Include header file `ghcautoconf.h` where the CPP macro `WORDS_BIGENDIAN` is defined. This finally fixes #17337 (in conjunction with commit 6c59cc71dc).
* Avoid race condition in hDuplicateToMoritz Kiefer2019-12-191-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In our codebase we have some code along the lines of ``` newStdout <- hDuplicate stdout stderr `hDuplicateTo` stdout ``` to avoid stray `putStrLn`s from corrupting a protocol (LSP) that is run over stdout. On CI we have seen a bunch of issues where `dup2` returned `EBUSY` so this fails with `ResourceExhausted` in Haskell. I’ve spent some time looking at the docs for `dup2` and the code in `base` and afaict the following race condition is being triggered here: 1. The user calls `hDuplicateTo stderr stdout`. 2. `hDuplicateTo` calls `hClose_help stdout_`, this closes the file handle for stdout. 3. The file handle for stdout is now free, so another thread allocating a file might get stdout. 4. If `dup2` is called while `stdout` (now pointing to something else) is half-open, it returns EBUSY. I think there might actually be an even worse case where `dup2` is run after FD 1 is fully open again. In that case, you will end up not just redirecting the original stdout to stderr but also the whatever resulted in that file handle being allocated. As far as I can tell, `dup2` takes care of closing the file handle itself so there is no reason to do this in `hDuplicateTo`. So this PR replaces the call to `hClose_help` by the only part of `hClose_help` that we actually care about, namely, `flushWriteBuffer`. I tested this on our codebase fairly extensively and haven’t been able to reproduce the issue with this patch.
* rts: Specialize hashing at call site rather than in struct.Crazycolorz52019-12-111-3/+3
| | | | | | | | | | | | | | | | Separate word and string hash tables on the type level, and do not store the hashing function. Thus when a different hash function is desire it is provided upon accessing the table. This is worst case the same as before the change, and in the majority of cases is better. Also mark the functions for aggressive inlining to improve performance. {F1686506} Reviewers: bgamari, erikd, simonmar Subscribers: rwbarton, thomie, carter GHC Trac Issues: #13165 Differential Revision: https://phabricator.haskell.org/D4889
* testsuite: Add (broken) test for #17510Ben Gamari2019-12-103-0/+20
|
* base: Fix incorrect @since in GHC.NaturalBen Gamari2019-12-101-1/+1
| | | | Fixes #17547.
* Fix comment typosGabor Greif2019-12-091-1/+1
| | | | | | | | | | | | | | | | The below is only necessary to fix the CI perf fluke that happened in 9897e8c8ef0b19a9571ef97a1d9bb050c1ee9121: ------------------------- Metric Decrease: T5837 T6048 T9020 T12425 T12234 T13035 T12150 Naperian -------------------------
* Fix typo in documentation of Base.hs.Matthias Braun2019-12-051-1/+1
|
* Make sameNat and sameSymbol proxy-polymorphicBodigrim2019-12-052-2/+2
|
* Use Int# primops in `Bits Int{8,16,32,64}` instancesSylvain Henry2019-12-031-16/+16
|
* base: Fix <unistd.h> #includeBen Gamari2019-12-021-2/+2
| | | | | | | Previously we were including <sys/unistd.h> which is available on glibc but not musl. (cherry picked from commit e44b695ca7cb5f3f99eecfba05c9672c6a22205e)
* Fix more typosBrian Wignall2019-12-021-1/+1
|
* Improve few Foreign.Marshal.Utils docsÖmer Sinan Ağacan2019-11-291-11/+21
| | | | | | | | In copyBytes and moveBytes mention which argument is source and which is destination. Also fixes some of the crazy indentation in the module and cleans trailing whitespace.
* Fix typos, using Wikipedia list of common typosBrian Wignall2019-11-287-8/+8
|
* Fix @since annotations for isResourceVanishedError and friends (#17488)Ryan Scott2019-11-271-3/+3
|
* On FreeBSD 12 sys/sysctl.h requires sys/types.hViktor Dukhovni2019-11-241-0/+1
| | | | | | | | | | | | | | Else build fails with: In file included from ExecutablePath.hsc:42: /usr/include/sys/sysctl.h:1062:25: error: unknown type name 'u_int'; did you mean 'int'? int sysctl(const int *, u_int, void *, size_t *, const void *, size_t); ^~~~~ int compiling libraries/base/dist-install/build/System/Environment/ExecutablePath_hsc_make.c failed (exit code 1) Perhaps also also other FreeBSD releases, but additional include will no harm even if not needed.
* Fix typosBrian Wignall2019-11-232-2/+2
|
* Stricten functions ins GHC.NaturalSebastian Graf2019-11-233-35/+62
| | | | | This brings `Natural` on par with `Integer` and fixes #17499. Also does some manual CSE for 0 and 1 literals.
* Target the IsList instance for ZipList at base-4.14.0.0 (#17489)Ryan Scott2019-11-231-1/+3
| | | | | | | | This moves the changelog entry about the instance from `base-4.15.0.0` to `base-4.14.0.0`. This accomplishes part (1) from #17489. [ci skip]
* Use pointer equality in Eq/Ord for ThreadIdRoland Zumkeller2019-11-191-12/+7
| | | | | | | | | | Changes (==) to use only pointer equality. This is safe because two threads are the same iff they have the same id. Changes `compare` to check pointer equality first and fall back on ids only in case of inequality. See discussion in #16761.
* testsuite: Skip T17414 on LinuxBen Gamari2019-11-171-0/+4
| | | | | | It is typical for $TMP to be a small tmpfson Linux. This test will fail in such cases since we must create a file larger than the filesystem. See #17459.
* Fixed issue #17435, missing Data instancesMario Blažević2019-11-172-0/+16
|
* base: Bump version to 4.14.0.0Ben Gamari2019-11-142-2/+2
| | | | | Metric Increase: T4801
* testsuite: Mark tests fragile in threaded2 as fragile in all concurrent waysBen Gamari2019-11-102-2/+2
|
* Fix incorrect pluralsBrian Wignall2019-11-091-1/+1
|
* Incorporate MR review suggestions; add change in changelogBrian Wignall2019-11-092-3/+6
|
* Add IsList instance for ZipList (closes #17433)ghc-8.11-startBrian Wignall2019-11-091-1/+9
|
* testsuite: Mark T17414 as fragile on WindowsBen Gamari2019-11-091-1/+5
| | | | | | This consistently times out on Windows as described in #17453. I have tried increasing the timeout multiplier to two yet it stills fails. Disabling until we have time to investigate.
* base: Fix TBA in changelogBen Gamari2019-11-091-2/+2
|
* base: Add missing imports in Windows locking implementationBen Gamari2019-11-071-0/+3
|
* Adding examples to Semigroup/monoidDan Brooks2019-11-062-0/+21
|
* Add +RTS --disable-delayed-os-memory-return. Fixes #17411.Niklas Hambüchen2019-11-011-0/+3
| | | | | | Sets `MiscFlags.disableDelayedOsMemoryReturn`. See the added `Note [MADV_FREE and MADV_DONTNEED]` for details.
* base: Ensure that failIO isn't SOURCE importedBen Gamari2019-11-014-9/+18
| | | | | | | | | failIO has useful information in its demand signature (specifically that it bottoms) which is hidden if it is SOURCE imported, as noted in #16588. Rejigger things such that we don't SOURCE import it. Metric Increase: T13701
* Fix rounding around 0taylorfausak2019-11-011-6/+9
|
* Implement `round` for `Ratio` that doesn't explode with `Natural`staylorfausak2019-11-011-0/+7
|
* base: Various haddock fixesBen Gamari2019-10-312-5/+5
| | | | Just a few things I found while looking at #17383.
* testsuite: Add test for #17414Ben Gamari2019-10-312-0/+20
|
* base: Clamp IO operation size to 2GB on DarwinBen Gamari2019-10-311-4/+17
| | | | | As reported in #17414, Darwin throws EINVAL in response to large writes.
* base: Split up file locking implementationBen Gamari2019-10-298-284/+352
| | | | This makes the CPP significantly easier to follow.
* base: Fix open-file lockingBen Gamari2019-10-292-19/+40
| | | | | | | | | The OFD locking path introduced in 3b784d440d4b01b4c549df7c9a3ed2058edfc780 due to #13945 appears to have never actually worked but we never noticed due to an oversight in the autoconf check. Fix it. Thanks to Oleg Grenrus for noticing this.
* Use `not#` primitive to implement Word's complementSylvain Henry2019-10-291-3/+1
|
* Implement shrinkSmallMutableArray# and resizeSmallMutableArray#.Andrew Martin2019-10-262-1/+42
| | | | | | | | | | | | | | | | | | | | | This is a part of GHC Proposal #25: "Offer more array resizing primitives". Resources related to the proposal: - Discussion: https://github.com/ghc-proposals/ghc-proposals/pull/121 - Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0025-resize-boxed.rst Only shrinkSmallMutableArray# is implemented as a primop since a library-space implementation of resizeSmallMutableArray# (in GHC.Exts) is no less efficient than a primop would be. This may be replaced by a primop in the future if someone devises a strategy for growing arrays in-place. The library-space implementation always copies the array when growing it. This commit also tweaks the documentation of the deprecated sizeofMutableByteArray#, removing the mention of concurrency. That primop is unsound even in single-threaded applications. Additionally, the non-negativity assertion on the existing shrinkMutableByteArray# primop has been removed since this predicate is trivially always true.
* Make documentation for byteSwap16 consistent with byteSwap32 (impl is same, ↵Brian Wignall2019-10-251-1/+1
| | | | with s/16/32)
* Merge non-moving garbage collectorBen Gamari2019-10-232-16/+23
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces a concurrent mark & sweep garbage collector to manage the old generation. The concurrent nature of this collector typically results in significantly reduced maximum and mean pause times in applications with large working sets. Due to the large and intricate nature of the change I have opted to preserve the fully-buildable history, including merge commits, which is described in the "Branch overview" section below. Collector design ================ The full design of the collector implemented here is described in detail in a technical note > B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell > Compiler" (2018) This document can be requested from @bgamari. The basic heap structure used in this design is heavily inspired by > K. Ueno & A. Ohori. "A fully concurrent garbage collector for > functional programs on multicore processors." /ACM SIGPLAN Notices/ > Vol. 51. No. 9 (presented at ICFP 2016) This design is intended to allow both marking and sweeping concurrent to execution of a multi-core mutator. Unlike the Ueno design, which requires no global synchronization pauses, the collector introduced here requires a stop-the-world pause at the beginning and end of the mark phase. To avoid heap fragmentation, the allocator consists of a number of fixed-size /sub-allocators/. Each of these sub-allocators allocators into its own set of /segments/, themselves allocated from the block allocator. Each segment is broken into a set of fixed-size allocation blocks (which back allocations) in addition to a bitmap (used to track the liveness of blocks) and some additional metadata (used also used to track liveness). This heap structure enables collection via mark-and-sweep, which can be performed concurrently via a snapshot-at-the-beginning scheme (although concurrent collection is not implemented in this patch). Implementation structure ======================== The majority of the collector is implemented in a handful of files: * `rts/Nonmoving.c` is the heart of the beast. It implements the entry-point to the nonmoving collector (`nonmoving_collect`), as well as the allocator (`nonmoving_allocate`) and a number of utilities for manipulating the heap. * `rts/NonmovingMark.c` implements the mark queue functionality, update remembered set, and mark loop. * `rts/NonmovingSweep.c` implements the sweep loop. * `rts/NonmovingScav.c` implements the logic necessary to scavenge the nonmoving heap. Branch overview =============== ``` * wip/gc/opt-pause: | A variety of small optimisations to further reduce pause times. | * wip/gc/compact-nfdata: | Introduce support for compact regions into the non-moving |\ collector | \ | \ | | * wip/gc/segment-header-to-bdescr: | | | Another optimization that we are considering, pushing | | | some segment metadata into the segment descriptor for | | | the sake of locality during mark | | | | * | wip/gc/shortcutting: | | | Support for indirection shortcutting and the selector optimization | | | in the non-moving heap. | | | * | | wip/gc/docs: | |/ Work on implementation documentation. | / |/ * wip/gc/everything: | A roll-up of everything below. |\ | \ | |\ | | \ | | * wip/gc/optimize: | | | A variety of optimizations, primarily to the mark loop. | | | Some of these are microoptimizations but a few are quite | | | significant. In particular, the prefetch patches have | | | produced a nontrivial improvement in mark performance. | | | | | * wip/gc/aging: | | | Enable support for aging in major collections. | | | | * | wip/gc/test: | | | Fix up the testsuite to more or less pass. | | | * | | wip/gc/instrumentation: | | | A variety of runtime instrumentation including statistics | | / support, the nonmoving census, and eventlog support. | |/ | / |/ * wip/gc/nonmoving-concurrent: | The concurrent write barriers. | * wip/gc/nonmoving-nonconcurrent: | The nonmoving collector without the write barriers necessary | for concurrent collection. | * wip/gc/preparation: | A merge of the various preparatory patches that aren't directly | implementing the GC. | | * GHC HEAD . . . ```
| *-. Merge branches 'wip/gc/optimize' and 'wip/gc/test' into wip/gc/everythingwip/gc/everythingBen Gamari2019-10-221-1/+1
| |\ \