aboutsummaryrefslogtreecommitdiffstats
path: root/io_buffer.c
Commit message (Collapse)AuthorAgeFilesLines
* Improve behavioural consistency of unallocated (zero length) `IO::Buffer`. ↵Samuel Williams2024-01-151-8/+6
| | | | | | | (#9532) This makes the behaviour of IO::Buffer.new(0) and IO::Buffer.new.slice(0, 0) consistent. Fixes https://bugs.ruby-lang.org/issues/19542 and https://bugs.ruby-lang.org/issues/18805.
* Fix Window private file mapping unlink EACCES issue. (#9358)Samuel Williams2023-12-271-6/+12
| | | | | | | * Don't return early. * Add missing `mapping` assignment. * Make debug logs conditional.
* Correctly release the underlying file mapping. (#9340)Samuel Williams2023-12-251-18/+22
| | | * Avoiding using `Tempfile` which was retaining the file preventing it from unlinking.
* IO::Buffer improvements and documentation. (#9329)Samuel Williams2023-12-251-179/+365
| | | | | | | | | | | * Restore experimental warnings. * Documentation and code structure improvements. * Improved validation of flags, clarified documentation of argument handling. * Remove inconsistent use of `Example:` and add example to `null?`. * Expose `IO::Buffer#private?` and add test.
* Implement IO::Buffer on VWAPeter Zhu2023-12-191-3/+1
|
* [DOC] Add document of IO::Buffer#hexdumpNobuyoshi Nakada2023-12-181-0/+1
|
* Implement Write Barriers on IO::BufferPeter Zhu2023-12-141-15/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | Benchmark: ``` require "benchmark" puts(Benchmark.measure do ary = 1_000_000.times.map { IO::Buffer.for("") } 10.times { GC.start(full_mark: false) } end) ``` Before: ``` 14.330119 0.051497 14.381616 ( 14.445106) ``` After: ``` 7.481152 0.040166 7.521318 ( 7.535209) ```
* Use xfree for IO::BufferPeter Zhu2023-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since IO::Buffer is allocated using TypedData_Make_Struct, it must use xfree to free the buffer otherwise it will cause more major GC to run. Example: ``` 10.times do 1_000_000.times { IO::Buffer.new(0) } puts "oldmalloc_increase_bytes: #{GC.stat(:oldmalloc_increase_bytes)}, major_gc_count: #{GC.stat(:major_gc_count)}" end ``` Before: ``` oldmalloc_increase_bytes: 14904176, major_gc_count: 3 oldmalloc_increase_bytes: 2399424, major_gc_count: 5 oldmalloc_increase_bytes: 5204640, major_gc_count: 6 oldmalloc_increase_bytes: 2199936, major_gc_count: 7 oldmalloc_increase_bytes: 34199936, major_gc_count: 7 oldmalloc_increase_bytes: 24223360, major_gc_count: 8 oldmalloc_increase_bytes: 5967616, major_gc_count: 9 oldmalloc_increase_bytes: 37967616, major_gc_count: 9 oldmalloc_increase_bytes: 9689792, major_gc_count: 10 oldmalloc_increase_bytes: 41689792, major_gc_count: 10 ``` After: ``` oldmalloc_increase_bytes: 117392, major_gc_count: 2 oldmalloc_increase_bytes: 26128, major_gc_count: 2 oldmalloc_increase_bytes: 71600, major_gc_count: 2 oldmalloc_increase_bytes: 117072, major_gc_count: 2 oldmalloc_increase_bytes: 17296, major_gc_count: 2 oldmalloc_increase_bytes: 62768, major_gc_count: 2 oldmalloc_increase_bytes: 108240, major_gc_count: 2 oldmalloc_increase_bytes: 153712, major_gc_count: 2 oldmalloc_increase_bytes: 53936, major_gc_count: 2 oldmalloc_increase_bytes: 99408, major_gc_count: 2 ```
* Don't warn generally for `IO::Buffer`, only on specific code paths e.g. ↵Samuel Williams2023-12-061-2/+0
| | | | `map`. (#9131)
* Fix `io_buffer_get_string` default length computation. (#8427)Samuel Williams2023-09-141-160/+181
| | | | | | | | * Fix `io_buffer_get_string` default length computation. When an offset bigger than the size is given, the resulting length will be computed incorrectly. Raise an argument error in this case. * Validate all arguments.
* [Bug #19754] Make `IO::Buffer#get_string` check `offset` range (#8016)Nobuyoshi Nakada2023-09-131-0/+3
|
* [DOC] Improved documentation. (#8319)Samuel Williams2023-08-291-2/+2
|
* Improve `read`/`write`/`pread`/`pwrite` consistency. (#7860)Samuel Williams2023-05-271-69/+116
| | | | | | | * Documentation consistency. * Improve consistency of `pread`/`pwrite` implementation when given length. * Remove HAVE_PREAD / HAVE_PWRITE - it is no longer optional.
* Improvements to `IO::Buffer` `read`/`write`/`pread`/`pwrite`. (#7826)Samuel Williams2023-05-241-77/+170
| | | - Fix IO::Buffer `read`/`write` to use a minimum length.
* Fix mutation on shared strings. (#7837)Samuel Williams2023-05-221-7/+12
|
* Rename `data` -> `buffer` for better readability. (#7836)Samuel Williams2023-05-221-386/+386
|
* Support `IO#pread` / `IO#pwrite` using fiber scheduler. (#7594)Samuel Williams2023-03-311-5/+22
| | | * Skip test if non-blocking file IO is not supported.
* Fix incorrect usage of `rb_fiber_scheduler_io_(p)(read|write)`. (#7593)Samuel Williams2023-03-251-4/+4
|
* IO::Buffer#resize: Free internal buffer if new size is zero (#7569)Kasumi Hanazuki2023-03-251-0/+5
| | | | | | | | | | `#resize(0)` on an IO::Buffer with internal buffer allocated will result in calling `realloc(data->base, 0)`. The behavior of `realloc` with size = 0 is implementation-defined (glibc frees the object and returns NULL, while BSDs return an inaccessible object). And thus such usage is deprecated in standard C (upcoming C23 will make it UB). To avoid this problem, just `free`s the memory when the new size is zero.
* Fix spelling (#7389)John Bampton2023-02-271-1/+1
|
* Adjust `else` style to be consistent in each files [ci skip]Nobuyoshi Nakada2023-02-261-11/+22
|
* Prefer RB_NUM2LONG for string length. (#7379)Samuel Williams2023-02-251-1/+1
|
* Add `IO::Buffer.string` for efficient string creation. (#7364)Samuel Williams2023-02-251-0/+30
|
* [Bug #19459] Remove unnecessary always-true checks (#7362)Nobuyoshi Nakada2023-02-231-17/+7
| | | | | `length` is a required argument for `IO::Buffer#read` and `IO::Buffer#write` methods, and `argc` is already checked with `rb_check_arity`. Also fix the call-seq of `IO::Buffer#read`.
* [DOC] Document new methods of IO::Buffer and Fiber::Scheduler (#7016)Victor Shepelev2022-12-241-10/+69
| | | Co-authored-by: Samuel Williams <samuel.williams@oriontransfer.co.nz>
* Fix missing handling of offset argument in `IO::Buffer` `pread` and ↵Samuel Williams2022-12-241-4/+18
| | | | `pwrite`. (#7012)
* Use consistent style [ci skip]Nobuyoshi Nakada2022-12-021-1/+2
|
* Fix typos (#6775)Yudai Takada2022-11-201-1/+1
| | | | | | | | | | | * s/Innteger/Integer/ * s/diretory/directory/ * s/Bufer/Buffer/ * s/defalt/default/ * s/covearge/coverage/
* Using UNDEF_P macroS-H-GAMELINKS2022-11-161-4/+4
|
* [DOC] Fix IO::Buffer#slice rdoc positionYusuke Nakamura2022-11-031-21/+21
| | | | Before this change, rdoc shows empty in 'slice' method section
* Fix format specifiers for `size_t`Nobuyoshi Nakada2022-10-261-1/+1
|
* Add support for anonymous shared IO buffers. (#6580)Samuel Williams2022-10-191-3/+34
|
* Improvements to IO::Buffer implementation and documentation. (#6525)Samuel Williams2022-10-121-136/+299
|
* Update `IO::Buffer` read/write to use rb_thread_io_blocking_region. (#6438)Samuel Williams2022-09-261-40/+121
|
* Add several new methods for getting and setting buffer contents. (#6434)Samuel Williams2022-09-261-103/+406
|
* [Bug #5317] Use `rb_off_t` instead of `off_t`Nobuyoshi Nakada2022-09-081-14/+14
| | | | Get rid of the conflict with system-provided small `off_t`.
* Adjust styles [ci skip]Nobuyoshi Nakada2022-07-271-1/+2
|
* Append semicolons [ci skip]Nobuyoshi Nakada2022-07-271-44/+44
|
* Make indents and newlines consistent [ci skip]Nobuyoshi Nakada2022-07-271-34/+46
|
* Fix a variable name typo in the docsShannon Skipper2022-06-251-2/+2
|
* Fix warnings by old gccNobuyoshi Nakada2022-06-231-2/+2
| | | | | | * Use PRIxSIZE instead of "z" * Fix sign-compare warning * Suppress unused-but-set-variable warning
* Add basic binary operators (and, or, xor, not) to `IO::Buffer`. (#5893)Samuel Williams2022-05-091-0/+405
|
* Fix rdoc of IO::Buffer [ci skip]Kazuhiro NISHIYAMA2022-05-091-14/+1
|
* Explicit handling of frozen strings in `IO::Buffer#for`. (#5892)Samuel Williams2022-05-091-25/+97
|
* io_buffer.c: use mremap based resizing only when mremap availableYuta Saito2022-01-071-1/+1
| | | | | some libc implementations (e.g. wasi-libc) define MREMAP_MAYMOVE, but don't have mremap itself, so guard the use of mremap by HAVE_MREMAP
* Remove UTF-8 from documentation.Samuel Williams2022-01-021-7/+0
|
* [DOC] Adjust IO::Buffer docs (#5374)Victor Shepelev2022-01-021-20/+57
|
* Fix typos [ci skip]Kazuhiro NISHIYAMA2021-12-251-1/+1
|
* Add fiber scheduler hooks for `pread`/`pwrite`, and add support to `IO::Buffer`.Samuel Williams2021-12-231-0/+173
|
* Extended interface for IO::Buffer & documentation.Samuel Williams2021-12-221-77/+735
|