summaryrefslogtreecommitdiff
path: root/io_buffer.c
AgeCommit message (Collapse)Author
2024-05-19Fix comment: Buffer.for(string) without block returns readonly bufferTOMITA Masahiro
2024-05-19Fix IO::Buffer commentTOMITA Masahiro
2024-05-09Fix format specifier for `DWORD`Nobuyoshi Nakada
2024-01-15Improve behavioural consistency of unallocated (zero length) `IO::Buffer`. ↵Samuel Williams
(#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.
2023-12-27Fix Window private file mapping unlink EACCES issue. (#9358)Samuel Williams
* Don't return early. * Add missing `mapping` assignment. * Make debug logs conditional.
2023-12-25Correctly release the underlying file mapping. (#9340)Samuel Williams
* Avoiding using `Tempfile` which was retaining the file preventing it from unlinking.
2023-12-25IO::Buffer improvements and documentation. (#9329)Samuel Williams
* 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.
2023-12-19Implement IO::Buffer on VWAPeter Zhu
2023-12-18[DOC] Add document of IO::Buffer#hexdumpNobuyoshi Nakada
2023-12-14Implement Write Barriers on IO::BufferPeter Zhu
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) ```
2023-12-12Use xfree for IO::BufferPeter Zhu
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 ```
2023-12-06Don't warn generally for `IO::Buffer`, only on specific code paths e.g. ↵Samuel Williams
`map`. (#9131)
2023-09-14Fix `io_buffer_get_string` default length computation. (#8427)Samuel Williams
* 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. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-09-13[Bug #19754] Make `IO::Buffer#get_string` check `offset` range (#8016)Nobuyoshi Nakada
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-08-29[DOC] Improved documentation. (#8319)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-05-27Improve `read`/`write`/`pread`/`pwrite` consistency. (#7860)Samuel Williams
* Documentation consistency. * Improve consistency of `pread`/`pwrite` implementation when given length. * Remove HAVE_PREAD / HAVE_PWRITE - it is no longer optional. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-05-24Improvements to `IO::Buffer` `read`/`write`/`pread`/`pwrite`. (#7826)Samuel Williams
- Fix IO::Buffer `read`/`write` to use a minimum length. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-05-22Fix mutation on shared strings. (#7837)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-05-22Rename `data` -> `buffer` for better readability. (#7836)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-03-31Support `IO#pread` / `IO#pwrite` using fiber scheduler. (#7594)Samuel Williams
* Skip test if non-blocking file IO is not supported. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-03-25Fix incorrect usage of `rb_fiber_scheduler_io_(p)(read|write)`. (#7593)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-03-25IO::Buffer#resize: Free internal buffer if new size is zero (#7569)Kasumi Hanazuki
`#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. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-02-27Fix spelling (#7389)John Bampton
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2023-02-26Adjust `else` style to be consistent in each files [ci skip]Nobuyoshi Nakada
2023-02-25Prefer RB_NUM2LONG for string length. (#7379)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-02-25Add `IO::Buffer.string` for efficient string creation. (#7364)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2023-02-23[Bug #19459] Remove unnecessary always-true checks (#7362)Nobuyoshi Nakada
`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`. Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-12-24[DOC] Document new methods of IO::Buffer and Fiber::Scheduler (#7016)Victor Shepelev
Co-authored-by: Samuel Williams <samuel.williams@oriontransfer.co.nz> Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-12-24Fix missing handling of offset argument in `IO::Buffer` `pread` and ↵Samuel Williams
`pwrite`. (#7012) Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-12-02Use consistent style [ci skip]Nobuyoshi Nakada
2022-11-20Fix typos (#6775)Yudai Takada
* s/Innteger/Integer/ * s/diretory/directory/ * s/Bufer/Buffer/ * s/defalt/default/ * s/covearge/coverage/ Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2022-11-16Using UNDEF_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/6721
2022-11-03[DOC] Fix IO::Buffer#slice rdoc positionYusuke Nakamura
Before this change, rdoc shows empty in 'slice' method section Notes: Merged: https://github.com/ruby/ruby/pull/6668
2022-10-26Fix format specifiers for `size_t`Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/6634
2022-10-19Add support for anonymous shared IO buffers. (#6580)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-10-12Improvements to IO::Buffer implementation and documentation. (#6525)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-09-26Update `IO::Buffer` read/write to use rb_thread_io_blocking_region. (#6438)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-09-26Add several new methods for getting and setting buffer contents. (#6434)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-09-08[Bug #5317] Use `rb_off_t` instead of `off_t`Nobuyoshi Nakada
Get rid of the conflict with system-provided small `off_t`. Notes: Merged: https://github.com/ruby/ruby/pull/6329
2022-07-27Adjust styles [ci skip]Nobuyoshi Nakada
2022-07-27Append semicolons [ci skip]Nobuyoshi Nakada
2022-07-27Make indents and newlines consistent [ci skip]Nobuyoshi Nakada
2022-06-25Fix a variable name typo in the docsShannon Skipper
Notes: Merged: https://github.com/ruby/ruby/pull/6060
2022-06-23Fix warnings by old gccNobuyoshi Nakada
* Use PRIxSIZE instead of "z" * Fix sign-compare warning * Suppress unused-but-set-variable warning
2022-05-09Add basic binary operators (and, or, xor, not) to `IO::Buffer`. (#5893)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-05-09Fix rdoc of IO::Buffer [ci skip]Kazuhiro NISHIYAMA
2022-05-09Explicit handling of frozen strings in `IO::Buffer#for`. (#5892)Samuel Williams
Notes: Merged-By: ioquatix <samuel@codeotaku.com>
2022-01-07io_buffer.c: use mremap based resizing only when mremap availableYuta Saito
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 Notes: Merged: https://github.com/ruby/ruby/pull/5401
2022-01-02Remove UTF-8 from documentation.Samuel Williams
2022-01-02[DOC] Adjust IO::Buffer docs (#5374)Victor Shepelev
Notes: Merged-By: ioquatix <samuel@codeotaku.com>